I have a C project with three C files and a .h file. I work in NetBeans. When I try to make an import I get this error:
gcc -o dist/Debug/GNU-Linux-x86/progetto build/Debug/GNU-Linux-x86/initialization.o build/Debug/GNU-Linux-x86/utility.o build/Debug/GNU-Linux-x86/model_parameters.o build/Debug/GNU-Linux-x86/condensation.o -L/usr/local/lib -lm I have to-lopencv_calib3d -lopencv_contrib -lopencv_core -lopencv_features2d -lopencv_flann -lopencv_gpu -lopencv_highgui -lopencv_imgproc -lopencv_legacy -lopencv_ml -lopencv_objdetect -lopencv_video -lXm -lXt -lXext -lX11 -lz -lpthread -lcurses -ldl
build/Debug/GNU-Linux-x86/model_parameters.o: file not recognized: File format not recognized
collect2: ld returned 1 exit status
I have tried to remove this import but the error doesn't disappear. I don't understand where the problem is.
Related
I got a gcc error. It is a strange error.
When I compile the 'muxing.c' without "–Wl,-rpath=./ffmpeg/lib", the code is successfully compiled.
gcc -o muxing muxing.c -I ./ffmpeg/include -L ./ffmpeg/lib -lavcodec -lavfilter -lavutil -lswresample -lavdevice -lavformat -lpostproc -lswscale -lm -lpthread -lasound
nvidia#nx:~/Desktop/project$ ls
ffmpeg Makefile muxing muxing.c test.cpp
But once I add "–Wl,-rpath=./ffmpeg/lib", the compiler give this error: –Wl,-rpath=./ffmpeg/lib: No such file or directory
gcc -o muxing muxing.c -I ./ffmpeg/include -L ./ffmpeg/lib -lavcodec -lavfilter -lavutil -lswresample -lavdevice -lavformat -lpostproc -lswscale -lm -lpthread -lasound –Wl,-rpath,'./ffmpeg/lib'
gcc: error: –Wl,-rpath=./ffmpeg/lib: No such file or directory
Makefile:7: recipe for target 'muxing' failed
make: *** [muxing] Error 1
The gcc option -I and -L can find the path, but '–Wl,-rpath=' cannot find this path. Why?
You have a typo in your option, probably because you copied it from a formatted text.
The leading "-" is not the correct character. So GCC interprets it as a filename character and tries to open a file with the name of the complete option "–Wl,-rpath,'./ffmpeg/lib'", as the error message tells.
I'm trying to build a software that uses gstreamer-1.0 and its plugins. I get this error when I try to make using the following g++ command:
g++ vis.cpp -o vis -O3 -D__STDC_CONSTANT_MACROS -std=c++11 -lopencv_highgui -lopencv_imgproc -lopencv_core -lpng -lv4l1 -lv4l2 -ldc1394 -lswscale -lavdevice -lavformat -lavcodec -lswresample -lavutil -lpthread -lbz2 -lz -lc -lrt -llzma -lva -Idependencies/include -Ldependencies/lib `pkg-config --cflags --libs gstreamer-1.0 gstreamer-base-1.0 gstreamer-app-1.0 gstreamer-pbutils-1.0 gtk+-2.0`
cap_gstreamer.cpp:(.text._ZN23CvVideoWriter_GStreamer4openEPKcid6CvSizeb+0x434): undefined reference to `gst_riff_create_video_caps'
collect2: error: ld returned 1 exit status
make: *** [vis] Error 1
Isn't gst_riff_create_video_caps already in the base plug-in? Or do I have to link another plugin for it?
I solved my problem. Obviously, I had to add -lgstriff-1.0 to the library flags as pointed out here:
http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gst-plugins-base-libs/html/gstreamer-riff.html
I am trying to compile following code webrtc2sip but getting following error.
root#dev1:/usr/local/src/webrtc2sip# g++ -g -O2 -o webrtc2sip webrtc2sip-mp_c2c.o webrtc2sip-mp_engine.o webrtc2sip-mp_mail.o webrtc2sip-mp_mediaproxy.o webrtc2sip-mp_mutex.o webrtc2sip-mp_net_transport.o webrtc2sip-mp_object.o webrtc2sip-mp_peer.o webrtc2sip-mp_proxyplugin.o webrtc2sip-mp_proxyplugin_consumer_audio.o webrtc2sip-mp_proxyplugin_consumer_video.o webrtc2sip-mp_proxyplugin_mgr.o webrtc2sip-mp_proxyplugin_producer_audio.o webrtc2sip-mp_proxyplugin_producer_video.o webrtc2sip-mp_session.o webrtc2sip-mp_session_av.o webrtc2sip-mp_wrap.o webrtc2sip-mp_db_sqlite.o webrtc2sip-sqlite3.o webrtc2sip-mp_db.o webrtc2sip-mp_db_model.o webrtc2sip-jsoncpp.o webrtc2sip-ActionConfig.o webrtc2sip-AudioResampler.o webrtc2sip-DDebug.o webrtc2sip-MediaContent.o webrtc2sip-MediaSessionMgr.o webrtc2sip-Msrp.o webrtc2sip-ProxyConsumer.o webrtc2sip-ProxyPluginMgr.o webrtc2sip-ProxyProducer.o webrtc2sip-SafeObject.o webrtc2sip-SipCallback.o webrtc2sip-SipEvent.o webrtc2sip-SipMessage.o webrtc2sip-SipSession.o webrtc2sip-SipStack.o webrtc2sip-SipUri.o webrtc2sip-SMSEncoder.o webrtc2sip-Xcap.o -L/usr/lib -L/usr/lib -L/usr/local/lib -ltinySAK -L/usr/local/lib -ltinyNET -L/usr/local/lib -ltinyHTTP -L/usr/local/lib -ltinySIP -L/usr/local/lib -ltinyDAV -L/usr/local/lib -ltinySDP -L/usr/local/lib -ltinyBFCP -L/usr/local/lib -ltinySIGCOMP -L/usr/local/lib -ltinyMEDIA -L/usr/local/lib -ltinyXCAP -L/usr/local/lib -ltinySMS -L/usr/local/lib -ltinyMSRP -L/usr/local/lib -ltinyRTP -L/usr/local/lib -ltinyIPSec -lxml2 -lpthread
/usr/bin/ld: webrtc2sip-sqlite3.o: undefined reference to symbol 'dlclose##GLIBC_2.2.5'
//lib/x86_64-linux-gnu/libdl.so.2: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
Edit:
I have tried following option in Makefile but no luck :(
LDFLAGS= -ldl
Solution:
Finally find it, used following option and it works!
./configure --prefix=$PREFIX CFLAGS='-lpthread' LDFLAGS='-ldl' LIBS='-ldl'
gcc -o clxd -m64 -L/usr/local/lib64 -L/usr/lib64 -L/usr/lib64/nptl
-Wl,-rpath,/home/y/lib64 -ldl -lrt -lpthread -lstdc++ -lgcc -lc -lm -lev -L/home/y/lib64 -Wl,-Bstatic -lboost_program_options -lboost_date_time -lboost_filesystem -lboost_regex -lboost_system -lboost_thread -llua -lcrypto -Wl,-Bdynamic -L/usr/lib
The above command is from a make file while executing make using V=1 (verbose) to understand if I have passed on directories properly or not. And it exits with the following error:
/usr/bin/ld: cannot find -lcrypto collect2: ld returned 1 exit status
My understanding from the gcc command, -Bstatic tries to statically link lib crypto (-lcrypto).
When I checked under /usr/lib64, I have the following files:
libcrypto.so -> libcrypto.so.1.0.1e
libcrypto.so.10 -> libcrypto.so.1.0.1e
libcrypto.so.1.0.1e
Does -Bstatic link the shared files statically or not? If not how do I get libcrypto.a?
I solved this on Linux/Macosx by installing libssl-dev.
sudo apt-get install libssl-dev
I was auditing cs107 at stanford online
The problem I ran into is with assignment 6, when I type "make" in terminal, the error message pops up. Basically, I miss two header files, which I guess can be got from the pre-compiled .lib file. But somehow it just doesn't work.
Here's part of the original make file:
CFLAGS = -D_REENTRANT -g -Wall -D__ostype_is_$(OSTYPE)__ -std=gnu99 -I/usr/class/cs107/include/ -Wno-unused-function $(DFLAG)
LDFLAGS = -L/usr/class/cs107/assignments/assn-6-rss-news-search-lib/$(OSTYPE) -L/usr/class/cs107/lib -lexpat -lrssnews $(PLATFORM_LIBS) $(THREAD_LIBS)
PFLAGS= -linker=/usr/pubsw/bin/ld -best-effort -threads=yes -max-threads=1000
Edit:
When I said "This is supposed to compile even without threading implementation", I meant that it should compile without FURTHER threading implementation by students.
So here's the error message with thread:
gcc -D_REENTRANT -g -Wall -D__ostype_is_linux__ -std=gnu99 -I/usr/class/cs107/include/ -Wno-unused-function -c -o rss-news-search.o rss-news-search.c
rss-news-search.c: In function ‘main’:
rss-news-search.c:109:3: warning: implicit declaration of function ‘InitThreadPackage’ [-Wimplicit-function-declaration]
gcc rss-news-search.o -D_REENTRANT -g -Wall -D__ostype_is_linux__ -std=gnu99 -I/usr/class/cs107/include/ -Wno-unused-function -L/home/h/cs107/assn-6-rss-news-search-lib/linux -L/usr/class/cs107/lib -L. -lexpat -lrssnews -lnsl -lpthread -lthread_107_linux -o rss-news-search
/usr/bin/ld: cannot find -lthread_107_linux
collect2: ld returned 1 exit status
make: *** [rss-news-search] Error 1
here's the error message without $(THREAD_LIBS):
gcc -D_REENTRANT -g -Wall -D__ostype_is_linux__ -std=gnu99 -I/usr/class/cs107/include/ -Wno-unused-function -c -o rss-news-search.o rss-news-search.c
rss-news-search.c: In function ‘main’:
rss-news-search.c:109:3: warning: implicit declaration of function ‘InitThreadPackage’ [-Wimplicit-function-declaration]
gcc rss-news-search.o -D_REENTRANT -g -Wall -D__ostype_is_linux__ -std=gnu99 -I/usr/class/cs107/include/ -Wno-unused-function -L/home/h/cs107/assn-6-rss-news-search-lib/linux -L/usr/class/cs107/lib -L. -lexpat -lrssnews -lnsl -lpthread -o rss-news-search
rss-news-search.o: In function `main':
/home/h/cs107/assn-6-rss-news-search/rss-news-search.c:109: undefined reference to `InitThreadPackage'
collect2: ld returned 1 exit status
make: *** [rss-news-search] Error 1
In the later case, if I comment out "InitThreadPackage", it compiles just fine.
This is the procedure to compile your project:
Create a file assn-6-rss-news-search/thread_107.h, and put this inside:
/* Empty header file */
Copy the library librssnews.a from assn-6-rss-news-search-lib/linux/ to assn-6-rss-news-search/
Modify the file rss-news-search.c by commenting the call to the function : InitThreadPackage on line 109:
//InitThreadPackage(false);
Modify the Makefile to include the path to the current directory (to be able to link to the library you've copied earlier librssnews.a):
The line 27 should look like this:
LDFLAGS = -L/usr/class/cs107/assignments/assn-6-rss-news-search-lib/$(OSTYPE) -L/usr/class/cs107/lib -L. -lexpat -lrssnews $(PLATFORM_LIBS) $(THREAD_LIBS)
Then:
make clean
make
EDIT :
When you got this error cannot find lthread_107_linux, Edit your Makefile to remove this $(THREAD_LIBS) on line 27:
LDFLAGS = -L/usr/class/cs107/assignments/assn-6-rss-news-search-lib/$(OSTYPE) -L/usr/class/cs107/lib -L. -lexpat -lrssnews $(PLATFORM_LIBS)
The class-specific header files, like thread_107.h are found in /usr/class/cs107/include/ on whatever machine the instructor is expecting the students to use. If you're not using that machine, you'll have to copy those include files or make your own.
The expat.h file is from an open source library. You'll need to install the appropriate package on the system you're compiling on. On Ubuntu, that's sudo apt-get install libexpat1-dev, but the package name should be similar on other distributions.