c++ - Linking curl after compiling fails in netbeans build -


if try this

g++ -o testapp main.cpp -i/usr/local/include -l/usr/local/lib -lcurl -lssl -lcrypto -lz -lz 

it works perfect...

but if want run sample app using netbeans directly gives me errors.

here 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 

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 `_curl_easy_init' /cygdrive/c/users/<my_username>/documents/netbeansprojects/sampleapp/main.cpp:25: undefined reference `_curl_easy_setopt' /cygdrive/c/users/<my_username>/documents/netbeansprojects/sampleapp/main.cpp:28: undefined reference `_curl_easy_setopt' /cygdrive/c/users/<my_username>/documents/netbeansprojects/sampleapp/main.cpp:29: undefined reference `_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 `_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 `_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 wrong here...?

the -l option needs before library specify -l on command line.

so if need -l/usr/local/lib libcurl (as in small sample) need first specify -l correct dir , -l correct lib name.


Comments

Popular posts from this blog

c++ - Is it possible to compile a VST on linux? -

java - Output of Eclipse is rubbish -

jquery - Confused with JSON data and normal data in Django ajax request -