编译链接后卷曲在NetBeans中构建失败 [英] Linking curl after compiling fails in netbeans build
本文介绍了编译链接后卷曲在NetBeans中构建失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果我试试这个
g++ -o testApp main.cpp -I/usr/local/include -L/usr/local/lib -lcurl -lssl -lcrypto -lz -lz
它的作品完美...
it works perfect...
但是,如果我想使用NetBeans运行我的示例应用程序直接它给了我一些错误。
BUT if i want to run my sample app by using netbeans directly it gives me some errors.
Makefile-Debug.mk这里的一部分
here a part of Makefile-Debug.mk
# Build Targets
.build-conf: ${BUILD_SUBPROJECTS}
"${MAKE}" -f nbproject/Makefile-${CND_CONF}.mk ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/SampleApp.exe
${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/SampleApp.exe: ${OBJECTFILES}
${MKDIR} -p ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}
${LINK.cc} -I/usr/local/lib -lcurl -lssl -lcrypto -lz -lz -o ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/SampleApp ${OBJECTFILES} ${LDLIBSOPTIONS}
${OBJECTDIR}/main.o: main.cpp
${MKDIR} -p ${OBJECTDIR}
${RM} $@.d
$(COMPILE.cc) -g -MMD -MP -MF $@.d -o ${OBJECTDIR}/main.o main.cpp
NetBeans的结果建立输出:
result of netbeans build output:
"/usr/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .clean-conf
make[1]: Entering directory `/cygdrive/c/Users/<MY_USERNAME>/Documents/NetBeansProjects/SampleApp'
rm -f -r build/Debug
rm -f dist/Debug/Cygwin-Windows/SampleApp.exe
make[1]: Leaving directory `/cygdrive/c/Users/<MY_USERNAME>/Documents/NetBeansProjects/SampleApp'
CLEAN SUCCESSFUL (total time: 1s)
"/usr/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
make[1]: Entering directory `/cygdrive/c/Users/<MY_USERNAME>/Documents/NetBeansProjects/SampleApp'
"/usr/bin/make" -f nbproject/Makefile-Debug.mk dist/Debug/Cygwin-Windows/SampleApp.exe
make[2]: Entering directory `/cygdrive/c/Users/<MY_USERNAME>/Documents/NetBeansProjects/SampleApp'
mkdir -p build/Debug/Cygwin-Windows
rm -f build/Debug/Cygwin-Windows/main.o.d
g++.exe -c -g -MMD -MP -MF build/Debug/Cygwin-Windows/main.o.d -o build/Debug/Cygwin-Windows/main.o main.cpp
mkdir -p dist/Debug/Cygwin-Windows
g++.exe -I/usr/local/lib -lcurl -lssl -lcrypto -lz -lz -o dist/Debug/Cygwin-Windows/SampleApp build/Debug/Cygwin-Windows/main.o -L/usr/local/lib
build/Debug/Cygwin-Windows/main.o: In function `main':
/cygdrive/c/Users/<MY_USERNAME>/Documents/NetBeansProjects/SampleApp/main.cpp:23: undefined reference to `_curl_easy_init'
/cygdrive/c/Users/<MY_USERNAME>/Documents/NetBeansProjects/SampleApp/main.cpp:25: undefined reference to `_curl_easy_setopt'
/cygdrive/c/Users/<MY_USERNAME>/Documents/NetBeansProjects/SampleApp/main.cpp:28: undefined reference to `_curl_easy_setopt'
/cygdrive/c/Users/<MY_USERNAME>/Documents/NetBeansProjects/SampleApp/main.cpp:29: undefined reference to `_curl_easy_setopt'
make[2]: Leaving directory `/cygdrive/c/Users/<MY_USERNAME>/Documents/NetBeansProjects/SampleApp'
/cygdrive/c/Users/<MY_USERNAME>/Documents/NetBeansProjects/SampleApp/main.cpp:31: undefined reference to `_curl_easy_perform'
make[1]: Leaving directory `/cygdrive/c/Users/<MY_USERNAME>/Documents/NetBeansProjects/SampleApp'
/cygdrive/c/Users/<MY_USERNAME>/Documents/NetBeansProjects/SampleApp/main.cpp:32: undefined reference to `_curl_easy_cleanup'
collect2: ld returned 1 exit status
make[2]: *** [dist/Debug/Cygwin-Windows/SampleApp.exe] Error 1
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2
BUILD FAILED (exit value 2, total time: 2s)
什么都可以错在这里...?
what can be wrong here...?
推荐答案
-L选项需要你在命令行上指定-l图书馆前要。
The -L option needs to be before the library you specify with -l on the command line.
所以如果你需要-L在/ usr /本地/与libcurl LIB(如您的小样本中),你需要的第一个的指定-L到正确的目录,然后用正确的lib -l名称。
So if you need -L/usr/local/lib for libcurl (as in your small sample) you need to first specify -L to the correct dir and then -l with the correct lib name.
这篇关于编译链接后卷曲在NetBeans中构建失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文