使用liboauth时链接错误。获取错误未定义引用`oauth_url_escape'

时间:2011-02-28 15:05:33

标签: c++ makefile

我在使用liboauth时遇到链接错误  代码ID

 #include <cstdlib>
    #include<oauth.h>
    using namespace std;

    /*
     * 
     */
    int main(int argc, char** argv) {
        oauth_url_escape("vivek");
        return 0;
    }

Makefile是由Netbeans自动生成的

   MKDIR=mkdir
CP=cp
GREP=grep
NM=nm
CCADMIN=CCadmin
RANLIB=ranlib
CC=gcc
CCC=g++
CXX=g++
FC=gfortran
AS=as

# Macros
CND_PLATFORM=GNU-Linux-x86
CND_CONF=Debug
CND_DISTDIR=dist

# Include project Makefile
include Makefile

# Object Directory
OBJECTDIR=build/${CND_CONF}/${CND_PLATFORM}

# Object Files
OBJECTFILES= \
    ${OBJECTDIR}/main.o


# C Compiler Flags
CFLAGS=

# CC Compiler Flags
CCFLAGS=
CXXFLAGS=

# Fortran Compiler Flags
FFLAGS=

# Assembler Flags
ASFLAGS=

# Link Libraries and Options
LDLIBSOPTIONS=-loauth

# Build Targets
.build-conf: ${BUILD_SUBPROJECTS}
    "${MAKE}"  -f nbproject/Makefile-Debug.mk dist/Debug/GNU-Linux-x86/cppapplication_4

dist/Debug/GNU-Linux-x86/cppapplication_4: ${OBJECTFILES}
    ${MKDIR} -p dist/Debug/GNU-Linux-x86
    ${LINK.cc} -o ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/cppapplication_4 ${OBJECTFILES} ${LDLIBSOPTIONS} 

${OBJECTDIR}/main.o: main.cpp 
    ${MKDIR} -p ${OBJECTDIR}
    ${RM} $@.d
    $(COMPILE.cc) -g -I../../Desktop/code_try/trunk/lib/out/linux/release64/liboauth-0.9.4/src -MMD -MP -MF $@.d -o ${OBJECTDIR}/main.o main.cpp

# Subprojects
.build-subprojects:

# Clean Targets
.clean-conf: ${CLEAN_SUBPROJECTS}
    ${RM} -r build/Debug
    ${RM} dist/Debug/GNU-Linux-x86/cppapplication_4

# Subprojects
.clean-subprojects:

# Enable dependency checking
.dep.inc: .depcheck-impl

include .dep.inc

我收到错误代码

 g++     -o dist/Debug/GNU-Linux-x86/cppapplication_4 build/Debug/GNU-Linux-x86/main.o ../../Desktop/cm_try/trunk/lib/out/linux/release64/sqlite/liboauth.a 
build/Debug/GNU-Linux-x86/main.o: In function `main':
/home/vivek/NetBeansProjects/CppApplication_4/main.cpp:16: undefined reference to `oauth_url_escape(char const*)'
collect2: ld returned 1 exit status
gmake[2]: *** [dist/Debug/GNU-Linux-x86/cppapplication_4] Error 1
gmake[1]: *** [.build-conf] Error 2
gmake: *** [.build-impl] Error 2
gmake[2]: Leaving directory `/home/vivek/NetBeansProjects/CppApplication_4'
gmake[1]: Leaving directory `/home/vivek/NetBeansProjects/CppApplication_4

1 个答案:

答案 0 :(得分:1)

我们只需要在C ++代码中更改include语句

extern "C" {
#include <oauth.h>
 }