使用 liboauth 时出现链接错误。出现错误未定义对“oauth_url_escape”的引用

发布于 2024-10-19 20:23:45 字数 2600 浏览 0 评论 0原文

使用 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} [email protected]
    $(COMPILE.cc) -g -I../../Desktop/code_try/trunk/lib/out/linux/release64/liboauth-0.9.4/src -MMD -MP -MF [email protected] -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

'

I am getting linking error when I am using liboauth
code id

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

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

Makefile is auto generated by Netbeans which is

   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} [email protected]
    $(COMPILE.cc) -g -I../../Desktop/code_try/trunk/lib/out/linux/release64/liboauth-0.9.4/src -MMD -MP -MF [email protected] -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

I am getting error code

 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

'

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

污味仙女 2024-10-26 20:23:45

我们只需要改变C++代码中的include语句

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

We just need to change include statement in C++ code

extern "C" {
#include <oauth.h>
 }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文