I use cmake to create my project using ffmpeg lib, the project is simple.
add_executable(testffmpeg main.cpp)
link_directories( /usr/lib/x86_64-linux-gnu )
target_link_libraries(testffmpeg libavcodec.a libavutil.a )
When make, there's lots of undefined reference errors (my default cxx compiler is clang by "export cxx=/usr/bin/clang++").
/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libavcodec.a(crystalhd.o): In function `receive_frame':(.text+0xef): undefined reference to `DtsProcOutputNoCopy'
but when I just use command, it's OK.
clang -o testffmpeg -lavutil -lavcodec main.cpp
while using gcc also get this error
gcc -o testffmpeg -lavutil -lavcodec main.cpp
so, how can I resolve this problem and where is the mistake?
You need add -lcrystalhd in your linker flags.
You can use code below to find all linker flags.
pkg-config --libs libavformat
-L/usr/local/lib -lavformat -lXv -lX11 -lXext -ldl -lvdpau -lva -lva-x11 -lX11 -lva -lva-drm -lva -lxcb -lxcb-shm -lxcb -lxcb-xfixes -lxcb-render -lxcb-shape -lxcb -lxcb-shape -lxcb -lsndio -ljack -lasound -lSDL2 -lx264 -lcrystalhd -lm -llzma -lbz2 -lz -pthread -lavcodec -lXv -lX11 -lXext -ldl -lvdpau -lva -lva-x11 -lX11 -lva -lva-drm -lva -lxcb -lxcb-shm -lxcb -lxcb-xfixes -lxcb-render -lxcb-shape -lxcb -lxcb-shape -lxcb -lsndio -ljack -lasound -lSDL2 -lx264 -lcrystalhd -lm -llzma -lbz2 -lz -pthread -lswresample -lm -lavutil -lm
Related
A user of xnec2c was trying to build on OSX with clang and got this error:
gcc --pedantic -Wall -std=gnu11 -O2 -g -Wformat -Werror=format-security -fpie -Wno-overlength-strings -DGTK_DISABLE_SINGLE_INCLUDES -DGDK_DISABLE_DEPRECATED -DGTK_DISABLE_DEPRECATED -DGSEAL_ENABLE -DGDK_PIXBUF_DISABLE_DEPRECATED -DG_DISABLE_DEPRECATED -D_FORTIFY_SOURCE=2 -fstack-protector-strong -fno-honor-nans -fno-signed-zeros -fno-math-errno -Wl,--export-dynamic -Wl,--as-needed -o xnec2c main.o mathlib.o measurements.o interface.o callbacks.o console.o callback_func.o calculations.o cmnd_edit.o geom_edit.o gnuplot.o draw.o draw_structure.o draw_radiation.o fields.o fork.o geometry.o ground.o xnec2c.o input.o matrix.o utils.o nec2_model.o network.o optimize.o plot_freqdata.o radiation.o rc_config.o shared.o somnec.o xnec2c-resources.o -L/opt/local/lib -lgtk-3 -lgdk-3 -lpangocairo-1.0 -lpango-1.0 -lharfbuzz -latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0 -lintl -lpthread -lm
ld: unknown option: --export-dynamic
clang: error: linker command failed with exit code 1 (use -v to see invocation)
(FYI: GTK Builder needs the export-dynamic linking flag.)
This discussion suggests making the double-dash a single dash:
-AM_LDFLAGS = -Wl,--export-dynamic
+AM_LDFLAGS = -Wl,-export-dynamic
However the user found that, actually, it needs a single dash and an underscore (maybe, still having trouble that could be related, but at least ld stopped barking about the option):
-AM_LDFLAGS = -Wl,--export-dynamic
+AM_LDFLAGS = -Wl,-export_dynamic
Questions:
Does single-dash -Wl,-export-dynamic work in both GCC and Clang?
Whats with the underscore version as -Wl,-export_dynamic?
How compatible is that option with older (and newer) versions of the GCC/Clang stacks?
Other considerations or best practice?
Both GNU ld and LLVM lld take --export-dynamic flag
ld that ships with OS X takes -export_dynamic flag
This has nothing to do with gcc or clang, these only pass the flag along to the linker
compile the latest v8 failed on linux platform.
linux, v8 using ninjia
ninja: Entering directory `out.gn/x64.release'
[14/571] LINK ./mksnapshot
o/x/args.gn+ buffers
FAILED: mksnapshot
../../third_party/llvm-build/Release+Asserts/bin/clang++ -pie -Wl,--fatal-warnings -fPIC -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -Wl,-z,defs -Wl,--as-needed -fuse-ld=lld -Wl,--icf=all -Wl,--color-diagnostics -m64 -rdynamic -pie -Wl,--disable-new-dtags -Wl,-O2 -Wl,--gc-sections -o "./mksnapshot" -Wl,--start-group #"./mksnapshot.rsp" -Wl,--end-group -latomic -ldl -lpthread -lrt
ld.lld: error: undefined symbol: void std::atomic_init(std::atomic*, bool)
referenced by module-compiler.cc:260 (../../src/wasm/module-compiler.cc:260)
obj/v8_base_without_compiler/module-compiler.o:(v8::internal::wasm::CompilationState::New(std::shared_ptr const&, std::shared_ptr))
link error
This problem has been solved by replacing std::atomic_init with straight assignment.
When compiling Wordnet 3.0 on Mac OSX, I get warnings about missing libraries.
library not found for -lX11
Remove all static X libraries from the Makefile.
Original
TK_LIBS = -L/usr/X11/lib -lX11 -Wl,-weak-lXss -lXext -L/usr/X11/lib -lXft -lX11 -L/usr/X11/lib -lfreetype -L/usr/X11/lib -lfontconfig -L/usr/X11/lib -lXrender -lX11 -lpthread -fra>
Changed
TK_LIBS = -L/usr/X11/lib -Wl -L/usr/X11/lib -lpthread -framework CoreFoundation -lz -lpthread -framework CoreFoundation.
Need to do this in src/Makefile.
I am trying to compile the examples of libhand, but I get the following output:
/usr/bin/ld: /usr/local/lib/libOgreMainStatic.a(OgreDynLib.cpp.o): undefined reference to symbol 'dlopen##GLIBC_2.1'
/usr/bin/ld: note: 'dlopen##GLIBC_2.1' is defined in DSO /usr/lib/gcc/i686-linux-gnu/4.6/../../../i386-linux-gnu/libdl.so so try adding it to the linker command line
/usr/lib/gcc/i686-linux-gnu/4.6/../../../i386-linux-gnu/libdl.so: could not read symbols: Invalid operation
collect2: ld returned 1 exit status
make[2]: *** [bend_one_finger] Error 1
make[1]: *** [CMakeFiles/bend_one_finger.dir/all] Error 2
make: *** [all] Error 2
The same thing happens when I try to compile my own example using the direction from libhand example. I believe it has something to do with the configuration file of libhand (LibHandConfig.cmake).
The same example compiles fine when I build it as a part of libhand, the problem occurs when I try to use libhand as a package (using cmake's FIND_PACKAGE() )
Not a complete answer, but just a step toward:
try to issue the following command after you got the make error:
/usr/bin/c++ CMakeFiles/example.dir/example.cc.o -o example -rdynamic -ldl -lXt /path/libs/libHand/hand_cpp/dist/libhand_hog.a /path/libs/libHand/hand_cpp/dist/libhand_renderer.a /path/libs/libHand/hand_cpp/dist/libhand_utils.a -lopencv_core -lopencv_flann -lopencv_imgproc -lopencv_highgui -lopencv_features2d -lopencv_calib3d -lopencv_cudaarithm -lopencv_cudawarping -lopencv_ml -lopencv_objdetect -lopencv_cuda -lopencv_cudafilters -lopencv_cudaimgproc -lopencv_video -lopencv_legacy -lopencv_cudaoptflow -lopencv_photo -lopencv_videostab -lopencv_ts -lopencv_cudacodec -lopencv_ocl -lopencv_superres -lopencv_cudafeatures2d -lopencv_nonfree -lopencv_stitching -lopencv_softcascade -lopencv_shape -lopencv_optim -lopencv_cudastereo -lopencv_cudabgsegm -lopencv_contrib -lopencv_bioinspired /path/libs/libHand/hand_cpp/dist/libdot_sceneloader.a /path/libs/libHand/hand_cpp/dist/libtinyxml.a /usr/local/lib/libOgreMainStatic.a -lzzip -lz -lfreeimage -lfreetype -lSM -lICE -lX11 -lXext -lXaw -lXrandr -ltbb /usr/local/lib/OGRE/libRenderSystem_GLStatic.a -lGLU -lGL /usr/local/lib/libOgreMainStatic.a -lzzip -lz -lfreeimage -lfreetype -lSM -lICE -lX11 -lXext -lXaw -lXrandr -ltbb /usr/local/lib/OGRE/libRenderSystem_GLStatic.a -lGLU -lGL /usr/local/lib/OGRE/libPlugin_OctreeSceneManagerStatic.a -ldl
If it succeeds than you have to manually add -ldl to the end of your libraries list ( target_link_libraries(example ${SOME_LIBS} ${OTHER_LIBS} -ldl) ). It seems that the configuration part of LibOGRE is slightly incorrect (it doesn't include a library libdl necessary to carelessly link application with it.
I have installed
libpam0g-dev libpam0g
But when I am linking to libpam I am getting error undefined reference to `pam_start'
and I am linker flags include -lpam.
Same code is working in Ubuntu 11.
Linking flags
-Wl,--start-group -lssl -lpam -lcrypto -lnspr4 -licui18n -licuuc -licudata -lcurl -lcares -lpthread -lpcrecpp -loauth -ldl -lrt -lz -Wl,--end-group
don't works
but this works
-Wl,--start-group -lssl -lpam -lcrypto -lnspr4 -licui18n -licuuc -licudata -lcurl -lcares -lpthread -lpcrecpp -loauth -ldl -lrt -lz -lpam -Wl,--end-group