I installed the OpenCV with the Pacman command. But i am getting hundred of lines of linking error. I compiled my program with the command
gcc example.cpp -o example `pkg-config --cflags --libs opencv4`
and the small part of the linking error is as follows.
usr/bin/ld: /usr/lib/gcc/x86_64-pc-linux-gnu/8.3.0/../../../../lib/libopencv_viz.so: undefined reference to `vtkRenderingFreeType_AutoInit_Destruct()'
/usr/bin/ld: /usr/lib/gcc/x86_64-pc-linux-gnu/8.3.0/../../../../lib/libopencv_viz.so: undefined reference to `vtkInteractorStyle::StartTwoPointer()'
/usr/bin/ld: /usr/lib/gcc/x86_64-pc-linux-gnu/8.3.0/../../../../lib/libopencv_viz.so: undefined reference to `vtkInteractorStyle::EndZoom()'
/usr/bin/ld: /usr/lib/gcc/x86_64-pc-linux-gnu/8.3.0/../../../../lib/libopencv_viz.so: undefined reference to `vtkSmartPointerBase::operator=(vtkObjectBase*)'
/usr/bin/ld: /usr/lib/gcc/x86_64-pc-linux-gnu/8.3.0/../../../../lib/libopencv_viz.so: undefined reference to `vtkOStrStreamWrapper::freeze(int)'
/usr/bin/ld: /usr/lib/gcc/x86_64-pc-linux-gnu/8.3.0/../../../../lib/libopencv_viz.so: undefined reference to `vtkCamera::SetUserTransform(vtkHomogeneousTransform*)'
/usr/bin/ld: /usr/lib/gcc/x86_64-pc-linux-gnu/8.3.0/../../../../lib/libopencv_viz.so: undefined reference to `vtkCommand::UnRegister()'
/usr/bin/ld: /usr/lib/gcc/x86_64-pc-linux-gnu/8.3.0/../../../../lib/libopencv_viz.so: undefined reference to `vtkRenderer::New()'
/usr/bin/ld: /usr/lib/gcc/x86_64-pc-linux-gnu/8.3.0/../../../../lib/libopencv_viz.so: undefined reference to `vtkInteractorStyle::StartDolly()'
/usr/bin/ld: /usr/lib/gcc/x86_64-pc-linux-gnu/8.3.0/../../../../lib/libopencv_viz.so: undefined reference to `vtkRenderer::SetActiveCamera(vtkCamera*)'
/usr/bin/ld: /usr/lib/gcc/x86_64-pc-linux-gnu/8.3.0/../../../../lib/libopencv_viz.so: undefined reference to `vtkInteractorObserver::ReleaseFocus()'
/usr/bin/ld: /usr/lib/gcc/x86_64-pc-linux-gnu/8.3.0/../../../../lib/libopencv_viz.so: undefined reference to `vtkInteractorObserver::ComputeDisplayToWorld(double, double, double, double*)'
/usr/bin/ld: /usr/lib/gcc/x86_64-pc-linux-gnu/8.3.0/../../../../lib/libopencv_viz.so: undefined reference to `vtkAlgorithm::Update(vtkInformation*)'
/usr/bin/ld: /usr/lib/gcc/x86_64-pc-linux-gnu/8.3.0/../../../../lib/libopencv_viz.so: undefined reference to `vtkMatrix4x4::New()'
opencv libraries themselves are there but libopencv_viz.so requires some symbols from the vtk library, which is listed as an optional dependency in opencv's PKGBUILD.
You should either just install it yourself (e.g. pacman -S [--asdeps] vtk), or complain to PKGBUILD maintaintes if you think the dependency should be made non-optional.
Related
I made a program that uses the source version of ffmpeg. I get the code from it's website and compile/configured it. The problem is I want to configure it with the libx264 flag so it looks like this:
./configure --enable-shared --enable-libx264 --enable-gpl
Ffmpeg itself compiles with no errors, however when I try to compile my own code using make I get this error:
/usr/bin/cmake -E cmake_link_script CMakeFiles/Renderer.dir/link.txt --verbose=1
/usr/bin/c++ -O3 -DNDEBUG CMakeFiles/Renderer.dir/src/main.cpp.o CMakeFiles/Renderer.dir/src/Application.cpp.o CMakeFiles/Renderer.dir/src/opengl/OpenGLRenderer.cpp.o CMakeFiles/Renderer.dir/src/opengl/texture.cpp.o CMakeFiles/Renderer.dir/src/opengl/text_render.cpp.o CMakeFiles/Renderer.dir/src/opengl/image_render.cpp.o CMakeFiles/Renderer.dir/src/logging/Log.cpp.o CMakeFiles/Renderer.dir/src/utils/color_converter.cpp.o CMakeFiles/Renderer.dir/src/utils/maths.cpp.o CMakeFiles/Renderer.dir/src/utils/sys_util.cpp.o CMakeFiles/Renderer.dir/src/types/segment.cpp.o CMakeFiles/Renderer.dir/src/types/timeline.cpp.o CMakeFiles/Renderer.dir/src/coms/json_parser.cpp.o CMakeFiles/Renderer.dir/src/coms/socket.cpp.o CMakeFiles/Renderer.dir/src/video_io/video_encoder.cpp.o CMakeFiles/Renderer.dir/src/video_io/video_decode.cpp.o CMakeFiles/Renderer.dir/src/video_io/audio_mixer.cpp.o CMakeFiles/Renderer.dir/lib/glad/src/glad.c.o -o bin/Renderer /usr/local/lib/libavformat.a /usr/local/lib/libavcodec.a /usr/local/lib/libswresample.a /usr/local/lib/libswscale.a /usr/local/lib/libavutil.a /usr/local/lib/libavdevice.a /usr/lib/x86_64-linux-gnu/libGL.so /usr/lib/x86_64-linux-gnu/libGLU.so /usr/lib/x86_64-linux-gnu/libfreetype.so lib/glfw/src/libglfw3.a lib/spdlog/libspdlog.a /usr/lib/x86_64-linux-gnu/libz.so /usr/lib/x86_64-linux-gnu/librt.a -lm -ldl /usr/lib/x86_64-linux-gnu/libX11.so
/usr/bin/ld: /usr/local/lib/libavcodec.a(libx264.o): in function `X264_frame':
/home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/libx264.c:349: undefined reference to `x264_picture_init'
/usr/bin/ld: /home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/libx264.c:518: undefined reference to `x264_encoder_encode'
/usr/bin/ld: /home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/libx264.c:551: undefined reference to `x264_encoder_delayed_frames'
/usr/bin/ld: /usr/local/lib/libavcodec.a(libx264.o): in function `reconfig_encoder':
/home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/libx264.c:297: undefined reference to `x264_encoder_reconfig'
/usr/bin/ld: /home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/libx264.c:212: undefined reference to `x264_encoder_reconfig'
/usr/bin/ld: /home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/libx264.c:224: undefined reference to `x264_encoder_reconfig'
/usr/bin/ld: /home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/libx264.c:250: undefined reference to `x264_encoder_reconfig'
/usr/bin/ld: /home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/libx264.c:217: undefined reference to `x264_encoder_reconfig'
/usr/bin/ld: /usr/local/lib/libavcodec.a(libx264.o):/home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/libx264.c:230: more undefined references to `x264_encoder_reconfig' follow
/usr/bin/ld: /usr/local/lib/libavcodec.a(libx264.o): in function `X264_close':
/home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/libx264.c:605: undefined reference to `x264_param_cleanup'
/usr/bin/ld: /home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/libx264.c:609: undefined reference to `x264_encoder_close'
/usr/bin/ld: /usr/local/lib/libavcodec.a(libx264.o): in function `parse_opts':
/home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/libx264.c:621: undefined reference to `x264_param_parse'
/usr/bin/ld: /usr/local/lib/libavcodec.a(libx264.o): in function `X264_init':
/home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/libx264.c:699: undefined reference to `x264_param_default'
/usr/bin/ld: /home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/libx264.c:704: undefined reference to `x264_param_default_preset'
/usr/bin/ld: /home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/libx264.c:729: undefined reference to `x264_param_parse'
/usr/bin/ld: /home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/libx264.c:763: undefined reference to `x264_param_parse'
/usr/bin/ld: /home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/libx264.c:795: undefined reference to `x264_levels'
/usr/bin/ld: /home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/libx264.c:820: undefined reference to `x264_param_parse'
/usr/bin/ld: /home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/libx264.c:821: undefined reference to `x264_param_parse'
/usr/bin/ld: /home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/libx264.c:822: undefined reference to `x264_param_parse'
/usr/bin/ld: /home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/libx264.c:823: undefined reference to `x264_param_parse'
/usr/bin/ld: /home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/libx264.c:883: undefined reference to `x264_param_apply_fastfirstpass'
/usr/bin/ld: /home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/libx264.c:924: undefined reference to `x264_param_apply_profile'
/usr/bin/ld: /home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/libx264.c:1012: undefined reference to `x264_param_parse'From the updated error it appears you're explicitly linking with /usr/local/lib/libavcodec.a etc. So the problem almost certainly lies with your CMakeLists.txt file(s). –
/usr/bin/ld: /home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/libx264.c:1032: undefined reference to `x264_encoder_open_163'
/usr/bin/ld: /home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/libx264.c:1041: undefined reference to `x264_encoder_headers'
/usr/bin/ld: /home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/libx264.c:1072: undefined reference to `x264_encoder_maximum_delayed_frames'
/usr/bin/ld: /usr/local/lib/libavcodec.a(vaapi_encode_h264.o): in function `vaapi_encode_h264_configure':
/home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/vaapi_encode_h264.c:1096: undefined reference to `vaQueryVendorString'
/usr/bin/ld: /usr/local/lib/libavcodec.a(vaapi_encode_h265.o): in function `vaapi_encode_h265_get_encoder_caps':
/home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/vaapi_encode_h265.c:1176: undefined reference to `vaGetConfigAttributes'
/usr/bin/ld: /home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/vaapi_encode_h265.c:1190: undefined reference to `vaGetConfigAttributes'
/usr/bin/ld: /usr/local/lib/libavcodec.a(vaapi_encode.o): in function `vaapi_encode_wait':
/home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/vaapi_encode.c:157: undefined reference to `vaSyncBuffer'
/usr/bin/ld: /home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/vaapi_encode.c:168: undefined reference to `vaSyncSurface'
/usr/bin/ld: /home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/vaapi_encode.c:170: undefined reference to `vaErrorStr'
/usr/bin/ld: /home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/vaapi_encode.c:161: undefined reference to `vaErrorStr'
/usr/bin/ld: /usr/local/lib/libavcodec.a(vaapi_encode.o): in function `vaapi_encode_free_output_buffer':
/home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/vaapi_encode.c:2412: undefined reference to `vaDestroyBuffer'
/usr/bin/ld: /usr/local/lib/libavcodec.a(vaapi_encode.o): in function `vaapi_encode_make_packed_header':
/home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/vaapi_encode.c:60: undefined reference to `vaCreateBuffer'
/usr/bin/ld: /home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/vaapi_encode.c:71: undefined reference to `vaCreateBuffer'
/usr/bin/ld: /home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/vaapi_encode.c:64: undefined reference to `vaErrorStr'
/usr/bin/ld: /home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/vaapi_encode.c:75: undefined reference to `vaErrorStr'
/usr/bin/ld: /usr/local/lib/libavcodec.a(vaapi_encode.o): in function `vaapi_encode_make_param_buffer':
/home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/vaapi_encode.c:101: undefined reference to `vaCreateBuffer'
/usr/bin/ld: /home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/vaapi_encode.c:104: undefined reference to `vaErrorStr'
/usr/bin/ld: /usr/local/lib/libavcodec.a(vaapi_encode.o): in function `vaapi_encode_alloc_output_buffer':
/home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/vaapi_encode.c:2430: undefined reference to `vaCreateBuffer'
/usr/bin/ld: /home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/vaapi_encode.c:2435: undefined reference to `vaErrorStr'
/usr/bin/ld: /home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/vaapi_encode.c:2447: undefined reference to `vaDestroyBuffer'
/usr/bin/ld: /usr/local/lib/libavcodec.a(vaapi_encode.o): in function `vaapi_encode_issue':
/home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/vaapi_encode.c:637: undefined reference to `vaDestroyBuffer'
/usr/bin/ld: /home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/vaapi_encode.c:583: undefined reference to `vaBeginPicture'
/usr/bin/ld: /home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/vaapi_encode.c:592: undefined reference to `vaRenderPicture'
/usr/bin/ld: /home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/vaapi_encode.c:601: undefined reference to `vaEndPicture'
/usr/bin/ld: /home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/vaapi_encode.c:618: undefined reference to `vaDestroyBuffer'
/usr/bin/ld: /home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/vaapi_encode.c:621: undefined reference to `vaErrorStr'
/usr/bin/ld: /home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/vaapi_encode.c:595: undefined reference to `vaErrorStr'
/usr/bin/ld: /home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/vaapi_encode.c:634: undefined reference to `vaEndPicture'
/usr/bin/ld: /home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/vaapi_encode.c:586: undefined reference to `vaErrorStr'
/usr/bin/ld: /home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/vaapi_encode.c:603: undefined reference to `vaErrorStr'
/usr/bin/ld: /usr/local/lib/libavcodec.a(vaapi_encode.o): in function `vaapi_encode_output':
/home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/vaapi_encode.c:668: undefined reference to `vaMapBuffer'
/usr/bin/ld: /home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/vaapi_encode.c:699: undefined reference to `vaUnmapBuffer'
/usr/bin/ld: /home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/vaapi_encode.c:701: undefined reference to `vaErrorStr'
/usr/bin/ld: /home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/vaapi_encode.c:671: undefined reference to `vaErrorStr'
/usr/bin/ld: /home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/vaapi_encode.c:715: undefined reference to `vaUnmapBuffer'
/usr/bin/ld: /usr/local/lib/libavcodec.a(vaapi_encode.o): in function `vaapi_encode_profile_entrypoint':
/home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/vaapi_encode.c:1381: undefined reference to `vaMaxNumProfiles'
/usr/bin/ld: /home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/vaapi_encode.c:1387: undefined reference to `vaQueryConfigProfiles'
/usr/bin/ld: /home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/vaapi_encode.c:1389: undefined reference to `vaErrorStr'
/usr/bin/ld: /home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/vaapi_encode.c:1411: undefined reference to `vaProfileStr'
/usr/bin/ld: /home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/vaapi_encode.c:1441: undefined reference to `vaMaxNumEntrypoints'
/usr/bin/ld: /home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/vaapi_encode.c:1447: undefined reference to `vaQueryConfigEntrypoints'
/usr/bin/ld: /home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/vaapi_encode.c:1450: undefined reference to `vaErrorStr'
/usr/bin/ld: /home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/vaapi_encode.c:1474: undefined reference to `vaEntrypointStr'
/usr/bin/ld: /home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/vaapi_encode.c:1499: undefined reference to `vaGetConfigAttributes'
/usr/bin/ld: /home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/vaapi_encode.c:1503: undefined reference to `vaErrorStr'
/usr/bin/ld: /usr/local/lib/libavcodec.a(vaapi_encode.o): in function `vaapi_encode_init_rate_control':
/home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/vaapi_encode.c:1574: undefined reference to `vaGetConfigAttributes'
/usr/bin/ld: /home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/vaapi_encode.c:1578: undefined reference to `vaErrorStr'
/usr/bin/ld: /usr/local/lib/libavcodec.a(vaapi_encode.o): in function `vaapi_encode_init_gop_structure':
/home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/vaapi_encode.c:1953: undefined reference to `vaGetConfigAttributes'
/usr/bin/ld: /home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/vaapi_encode.c:1958: undefined reference to `vaErrorStr'
/usr/bin/ld: /home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/vaapi_encode.c:1977: undefined reference to `vaGetConfigAttributes'
/usr/bin/ld: /home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/vaapi_encode.c:1982: undefined reference to `vaErrorStr'
/usr/bin/ld: /usr/local/lib/libavcodec.a(vaapi_encode.o): in function `vaapi_encode_init_slice_structure':
/home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/vaapi_encode.c:2206: undefined reference to `vaGetConfigAttributes'
/usr/bin/ld: /home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/vaapi_encode.c:2211: undefined reference to `vaErrorStr'
/usr/bin/ld: /usr/local/lib/libavcodec.a(vaapi_encode.o): in function `vaapi_encode_init_packed_headers':
/home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/vaapi_encode.c:2269: undefined reference to `vaGetConfigAttributes'
/usr/bin/ld: /home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/vaapi_encode.c:2274: undefined reference to `vaErrorStr'
/usr/bin/ld: /usr/local/lib/libavcodec.a(vaapi_encode.o): in function `vaapi_encode_init_roi':
/home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/vaapi_encode.c:2377: undefined reference to `vaGetConfigAttributes'
/usr/bin/ld: /home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/vaapi_encode.c:2382: undefined reference to `vaErrorStr'
/usr/bin/ld: /usr/local/lib/libavcodec.a(vaapi_encode.o): in function `vaapi_encode_init_quality':
/home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/vaapi_encode.c:2331: undefined reference to `vaGetConfigAttributes'
/usr/bin/ld: /home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/vaapi_encode.c:2336: undefined reference to `vaErrorStr'
/usr/bin/ld: /usr/local/lib/libavcodec.a(vaapi_encode.o): in function `vaapi_encode_init_max_frame_size':
/home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/vaapi_encode.c:1902: undefined reference to `vaGetConfigAttributes'
/usr/bin/ld: /home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/vaapi_encode.c:1908: undefined reference to `vaErrorStr'
/usr/bin/ld: /usr/local/lib/libavcodec.a(vaapi_encode.o): in function `ff_vaapi_encode_init':
/home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/vaapi_encode.c:2630: undefined reference to `vaCreateConfig'
/usr/bin/ld: /home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/vaapi_encode.c:2635: undefined reference to `vaErrorStr'
/usr/bin/ld: /home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/vaapi_encode.c:2646: undefined reference to `vaCreateContext'
/usr/bin/ld: /home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/vaapi_encode.c:2653: undefined reference to `vaErrorStr'
/usr/bin/ld: /home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/vaapi_encode.c:2727: undefined reference to `vaSyncBuffer'
/usr/bin/ld: /usr/local/lib/libavcodec.a(vaapi_encode.o): in function `ff_vaapi_encode_close':
/home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/vaapi_encode.c:2762: undefined reference to `vaDestroyContext'
/usr/bin/ld: /home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/vaapi_encode.c:2767: undefined reference to `vaDestroyConfig'
/usr/bin/ld: /usr/local/lib/libavcodec.a(vaapi_decode.o): in function `ff_vaapi_decode_destroy_buffers':
/home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/vaapi_decode.c:133: undefined reference to `vaDestroyBuffer'
/usr/bin/ld: /home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/vaapi_decode.c:143: undefined reference to `vaDestroyBuffer'
/usr/bin/ld: /home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/vaapi_decode.c:146: undefined reference to `vaErrorStr'
/usr/bin/ld: /home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/vaapi_decode.c:136: undefined reference to `vaErrorStr'
/usr/bin/ld: /usr/local/lib/libavcodec.a(vaapi_decode.o): in function `vaapi_decode_make_config':
/home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/vaapi_decode.c:468: undefined reference to `vaMaxNumProfiles'
/usr/bin/ld: /home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/vaapi_decode.c:476: undefined reference to `vaQueryConfigProfiles'
/usr/bin/ld: /home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/vaapi_decode.c:540: undefined reference to `vaCreateConfig'
/usr/bin/ld: /usr/local/lib/libavcodec.a(vaapi_decode.o): in function `vaapi_decode_find_best_format':
/home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/vaapi_decode.c:310: undefined reference to `vaQuerySurfaceAttributes'
/usr/bin/ld: /home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/vaapi_decode.c:322: undefined reference to `vaQuerySurfaceAttributes'
/usr/bin/ld: /usr/local/lib/libavcodec.a(vaapi_decode.o): in function `vaapi_decode_make_config':
/home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/vaapi_decode.c:624: undefined reference to `vaDestroyConfig'
/usr/bin/ld: /home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/vaapi_decode.c:479: undefined reference to `vaErrorStr'
/usr/bin/ld: /home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/vaapi_decode.c:544: undefined reference to `vaErrorStr'
/usr/bin/ld: /usr/local/lib/libavcodec.a(vaapi_decode.o): in function `vaapi_decode_find_best_format':
/home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/vaapi_decode.c:325: undefined reference to `vaErrorStr'
/usr/bin/ld: /home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/vaapi_decode.c:313: undefined reference to `vaErrorStr'
/usr/bin/ld: /usr/local/lib/libavcodec.a(vaapi_decode.o): in function `ff_vaapi_decode_make_param_buffer':
/home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/vaapi_decode.c:44: undefined reference to `vaCreateBuffer'
/usr/bin/ld: /home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/vaapi_decode.c:47: undefined reference to `vaErrorStr'
/usr/bin/ld: /usr/local/lib/libavcodec.a(vaapi_decode.o): in function `ff_vaapi_decode_make_slice_buffer':
/home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/vaapi_decode.c:90: undefined reference to `vaCreateBuffer'
/usr/bin/ld: /home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/vaapi_decode.c:104: undefined reference to `vaCreateBuffer'
/usr/bin/ld: /home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/vaapi_decode.c:95: undefined reference to `vaErrorStr'
/usr/bin/ld: /home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/vaapi_decode.c:109: undefined reference to `vaErrorStr'
/usr/bin/ld: /home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/vaapi_decode.c:112: undefined reference to `vaDestroyBuffer'
/usr/bin/ld: /usr/local/lib/libavcodec.a(vaapi_decode.o): in function `ff_vaapi_decode_issue':
/home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/vaapi_decode.c:163: undefined reference to `vaBeginPicture'
/usr/bin/ld: /home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/vaapi_decode.c:172: undefined reference to `vaRenderPicture'
/usr/bin/ld: /home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/vaapi_decode.c:181: undefined reference to `vaRenderPicture'
/usr/bin/ld: /home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/vaapi_decode.c:190: undefined reference to `vaEndPicture'
/usr/bin/ld: /home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/vaapi_decode.c:192: undefined reference to `vaErrorStr'
/usr/bin/ld: /home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/vaapi_decode.c:166: undefined reference to `vaErrorStr'
/usr/bin/ld: /home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/vaapi_decode.c:210: undefined reference to `vaEndPicture'
/usr/bin/ld: /home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/vaapi_decode.c:212: undefined reference to `vaErrorStr'
/usr/bin/ld: /home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/vaapi_decode.c:175: undefined reference to `vaErrorStr'
/usr/bin/ld: /home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/vaapi_decode.c:184: undefined reference to `vaErrorStr'
/usr/bin/ld: /usr/local/lib/libavcodec.a(vaapi_decode.o): in function `ff_vaapi_common_frame_params':
/home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/vaapi_decode.c:650: undefined reference to `vaDestroyConfig'
/usr/bin/ld: /usr/local/lib/libavcodec.a(vaapi_decode.o): in function `ff_vaapi_decode_uninit':
/home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/vaapi_decode.c:707: undefined reference to `vaDestroyContext'
/usr/bin/ld: /home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/vaapi_decode.c:709: undefined reference to `vaErrorStr'
/usr/bin/ld: /home/turgut/Desktop/CppProjects/videoo-render/lib/ffmpeg/libavcodec/vaapi_decode.c:715: undefined reference to `vaDestroyConfig'
(The error is a bit longer but I think this is ample for now.)
The thing is, this code also runs on the cloud and compiles just fine without the --enable-libx264 flags. And inside the cloud, it works just fine even with the libx264 flag. But when I follow the exact same steps as the cloud and try to compile it locally, it gives this error.
Here are the steps I have followed:
First I removed ffmpeg (It was a bit messy) using sudo apt-get --purge autoremove ffmpeg then I made sure its deleted by searching find / -name ffmpeg and manually deleting my findings. Then, I ran apt-get install -y libx264-dev, followed by ./configure --enable-shared --enable-libx264 --enable-gpl inside the directory where I have downloaded the source files. Then ran make and make install where ffmpeg source files are. I ran ldconfig so it can detect shared libs (This is how it works on the cloud) and finally ran make on my own codes directory and got the error mentioned.
Here is my CMakeFile:
cmake_minimum_required(VERSION 3.7)
project(Renderer C CXX)
set(CMAKE_CXX_STANDARD 14)
SET( EXECUTABLE_OUTPUT_PATH ${dir}/bin )
set( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bin )
add_definitions(-DGL_SILENCE_DEPRECATION)
add_definitions("-g -lglad -lGL -lGLU -lX11 -lvdpau -lz -lva -lavformat -lavcodec- -lswscale -lavutil -lavfiter -lswresample
-lavdevice -lpostproc -loa -lz -lx264 -llzma -lbz2 -lrt -lx264 -pthread -lm -lva-drm -lva-x11")
list(APPEND SOURCES
...
)
find_path(AVCODEC_INCLUDE_DIR libavcodec/avcodec.h)
find_library(AVCODEC_LIBRARY avcodec)
find_path(AVFORMAT_INCLUDE_DIR libavformat/avformat.h)
find_library(AVFORMAT_LIBRARY avformat)
find_path(AVDEVICE_INCLUDE_DIR libavdevice/avdevice.h)
find_library(AVDEVICE_LIBRARY avdevice)
find_path(AVCODEC_INCLUDE_DIR libavcodec/avcodec.h)
find_library(AVCODEC_LIBRARY avcodec)
find_path(AVUTIL_INCLUDE_DIR libavutil/avutil.h)
find_library(AVUTIL_LIBRARY avutil)
find_path(SWRESAMPLE_INCLUDE_DIR libswresample/swresample.h)
find_library(SWRESAMPLE_LIBRARY swresample)
find_path(SWSCALE_INCLUDE_DIR libswscale/swscale.h)
find_library(SWSCALE_LIBRARY swscale)
set(THREADS_PREFER_PTHREAD_FLAG ON)
add_executable(Renderer src/main.cpp src/Application.cpp src/Application.h ${SOURCES})
target_link_libraries(Renderer PRIVATE Threads::Threads)
list(APPEND EXTRA_LIBS
"-lGL -lGLU -lX11 -lz -lva -lswresample -lx264 -shared -lvdpau -lva -lm -lva-drm -lva-x11"
)
target_include_directories(Renderer PRIVATE
${AVFORMAT_INCLUDE_DIR}
${AVCODEC_INCLUDE_DIR}
${SWRESAMPLE_INCLUDE_DIR}
${SWSCALE_INCLUDE_DIR}
${AVUTIL_INCLUDE_DIR}
${AVDEVICE_INCLUDE_DIR}
)
target_link_libraries(Renderer PRIVATE
${AVFORMAT_LIBRARY}
${AVCODEC_LIBRARY}
${SWRESAMPLE_LIBRARY}
${SWSCALE_LIBRARY}
${AVUTIL_LIBRARY}
${AVDEVICE_LIBRARY}
)
Like I said, it works on the cloud just the way it is and everything works without the --enable-libx264 flag.
How can I fix this? I'm on ubuntu 22+
I followed the instructions on the official website to build and install Pistache.io. Now, I'm trying to build this sample program from the official repository: https://github.com/pistacheio/pistache/blob/master/examples/hello_server.cc
However, I get the following error even though I've used the -lpistache flag:
g++ -Wall -Wextra -std=c++17 -lpistache hellopis.cpp -o hellopis
/usr/bin/ld: /tmp/ccuHXrLC.o: warning: relocation against `_ZTVN8Pistache3Tcp7HandlerE' in read-only section `.text._ZN8Pistache3Tcp7HandlerC2ERKS1_[_ZN8Pistache3Tcp7HandlerC5ERKS1_]'
/usr/bin/ld: /tmp/ccuHXrLC.o: in function `main':
hellopis.cpp:(.text+0x3b): undefined reference to `Pistache::Port::Port(unsigned short)'
/usr/bin/ld: hellopis.cpp:(.text+0x4a): undefined reference to `Pistache::IP::any()'
/usr/bin/ld: hellopis.cpp:(.text+0x9f): undefined reference to `Pistache::Address::Address(Pistache::IP, Pistache::Port)'
/usr/bin/ld: hellopis.cpp:(.text+0xb2): undefined reference to `Pistache::Http::Endpoint::options()'
/usr/bin/ld: hellopis.cpp:(.text+0xc6): undefined reference to `Pistache::Http::Endpoint::Options::threads(int)'
/usr/bin/ld: hellopis.cpp:(.text+0x103): undefined reference to `Pistache::Http::Endpoint::Endpoint(Pistache::Address const&)'
/usr/bin/ld: hellopis.cpp:(.text+0x11c): undefined reference to `Pistache::Http::Endpoint::init(Pistache::Http::Endpoint::Options const&)'
/usr/bin/ld: hellopis.cpp:(.text+0x151): undefined reference to `Pistache::Http::Endpoint::setHandler(std::shared_ptr<Pistache::Http::Handler> const&)'
/usr/bin/ld: hellopis.cpp:(.text+0x178): undefined reference to `Pistache::Http::Endpoint::serve()'
/usr/bin/ld: /tmp/ccuHXrLC.o: in function `Pistache::Http::Endpoint::~Endpoint()':
hellopis.cpp:(.text._ZN8Pistache4Http8EndpointD2Ev[_ZN8Pistache4Http8EndpointD5Ev]+0x3c): undefined reference to `Pistache::Tcp::Listener::~Listener()'
/usr/bin/ld: /tmp/ccuHXrLC.o: in function `Pistache::Async::Promise<long> Pistache::Http::ResponseWriter::send<13ul>(Pistache::Http::Code, char const (&) [13ul], Pistache::Http::Mime::MediaType const&)':
hellopis.cpp:(.text._ZN8Pistache4Http14ResponseWriter4sendILm13EEENS_5Async7PromiseIlEENS0_4CodeERAT__KcRKNS0_4Mime9MediaTypeE[_ZN8Pistache4Http14ResponseWriter4sendILm13EEENS_5Async7PromiseIlEENS0_4CodeERAT__KcRKNS0_4Mime9MediaTypeE]+0x3b): undefined reference to `Pistache::Http::ResponseWriter::sendImpl(Pistache::Http::Code, char const*, unsigned long, Pistache::Http::Mime::MediaType const&)'
/usr/bin/ld: /tmp/ccuHXrLC.o: in function `Pistache::Tcp::Handler::Handler(Pistache::Tcp::Handler const&)':
hellopis.cpp:(.text._ZN8Pistache3Tcp7HandlerC2ERKS1_[_ZN8Pistache3Tcp7HandlerC5ERKS1_]+0x26): undefined reference to `vtable for Pistache::Tcp::Handler'
/usr/bin/ld: /tmp/ccuHXrLC.o: in function `Pistache::Http::Handler::Handler(Pistache::Http::Handler const&)':
hellopis.cpp:(.text._ZN8Pistache4Http7HandlerC2ERKS1_[_ZN8Pistache4Http7HandlerC5ERKS1_]+0x26): undefined reference to `vtable for Pistache::Http::Handler'
/usr/bin/ld: /tmp/ccuHXrLC.o: in function `Pistache::Http::Handler::~Handler()':
hellopis.cpp:(.text._ZN8Pistache4Http7HandlerD2Ev[_ZN8Pistache4Http7HandlerD5Ev]+0xf): undefined reference to `vtable for Pistache::Http::Handler'
/usr/bin/ld: hellopis.cpp:(.text._ZN8Pistache4Http7HandlerD2Ev[_ZN8Pistache4Http7HandlerD5Ev]+0x22): undefined reference to `Pistache::Tcp::Handler::~Handler()'
/usr/bin/ld: /tmp/ccuHXrLC.o: in function `Pistache::Http::Handler::Handler()':
hellopis.cpp:(.text._ZN8Pistache4Http7HandlerC2Ev[_ZN8Pistache4Http7HandlerC5Ev]+0x15): undefined reference to `Pistache::Tcp::Handler::Handler()'
/usr/bin/ld: hellopis.cpp:(.text._ZN8Pistache4Http7HandlerC2Ev[_ZN8Pistache4Http7HandlerC5Ev]+0x1c): undefined reference to `vtable for Pistache::Http::Handler'
/usr/bin/ld: hellopis.cpp:(.text._ZN8Pistache4Http7HandlerC2Ev[_ZN8Pistache4Http7HandlerC5Ev]+0x7b): undefined reference to `Pistache::Tcp::Handler::~Handler()'
/usr/bin/ld: /tmp/ccuHXrLC.o:(.data.rel.ro._ZTV12HelloHandler[_ZTV12HelloHandler]+0x28): undefined reference to `Pistache::Http::Handler::onInput(char const*, unsigned long, std::shared_ptr<Pistache::Tcp::Peer> const&)'
/usr/bin/ld: /tmp/ccuHXrLC.o:(.data.rel.ro._ZTV12HelloHandler[_ZTV12HelloHandler]+0x30): undefined reference to `Pistache::Http::Handler::onConnection(std::shared_ptr<Pistache::Tcp::Peer> const&)'
/usr/bin/ld: /tmp/ccuHXrLC.o:(.data.rel.ro._ZTV12HelloHandler[_ZTV12HelloHandler]+0x38): undefined reference to `Pistache::Tcp::Handler::onDisconnection(std::shared_ptr<Pistache::Tcp::Peer> const&)'
/usr/bin/ld: /tmp/ccuHXrLC.o:(.data.rel.ro._ZTV12HelloHandler[_ZTV12HelloHandler]+0x48): undefined reference to `Pistache::Http::Handler::onTimeout(Pistache::Http::Request const&, Pistache::Http::ResponseWriter)'
/usr/bin/ld: /tmp/ccuHXrLC.o:(.data.rel.ro._ZTI12HelloHandler[_ZTI12HelloHandler]+0x10): undefined reference to `typeinfo for Pistache::Http::Handler'
/usr/bin/ld: warning: creating DT_TEXTREL in a PIE
collect2: error: ld returned 1 exit status
make: *** [<builtin>: hellopis] Error 1
What is this error and how can I resolve it?
The problem was resolved when I invoked the g++ command myself without using the Makefile. In particular, I ran the following command: g++ -Wall -Wextra -std=c++17 hellopis.cpp -o hellopis -lpistache.
My Makefile is as follows:
CXXFLAGS=-Wall -Wextra -std=c++17
LDFLAGS=-lpistache
Trying to compile my silly hello-world SFML project for test. But getting strange error messages from linker. (When I compile with shared lib's - everything is OK.)
g++ -DSFML_STATIC -O2 -no-pie -fno-pie -o main main.cpp -L/home/uzzer/LIB/SFML-2.5.1/lib -lstdc++ -lc -lm -ldl -lX11 -lGL -lGLU -lsfml-system-s -lsfml-graphics-s -lsfml-window-s
Error messages:
/usr/bin/ld: /home/uzzer/LIB/SFML-2.5.1/lib/libsfml-graphics-s.a(RenderTarget.cpp.o): in function `(anonymous namespace)::equationToGlConstant(sf::BlendMode::Equation) [clone .part.0]':
RenderTarget.cpp:(.text+0x8): undefined reference to `sf::err()'
/usr/bin/ld: /home/uzzer/LIB/SFML-2.5.1/lib/libsfml-graphics-s.a(RenderTarget.cpp.o): in function `(anonymous namespace)::factorToGlConstant(sf::BlendMode::Factor) [clone .part.0]':
RenderTarget.cpp:(.text+0xa8): undefined reference to `sf::err()'
/usr/bin/ld: /home/uzzer/LIB/SFML-2.5.1/lib/libsfml-graphics-s.a(RenderTarget.cpp.o): in function `sf::RenderTarget::clear(sf::Color const&)':
RenderTarget.cpp:(.text+0x2c9): undefined reference to `glClearColor'
/usr/bin/ld: /home/uzzer/LIB/SFML-2.5.1/lib/libsfml-graphics-s.a(RenderTarget.cpp.o): in function `sf::RenderTarget::popGLStates()':
RenderTarget.cpp:(.text+0x854): undefined reference to `glMatrixMode'
/usr/bin/ld: RenderTarget.cpp:(.text+0x859): undefined reference to `glPopMatrix'
/usr/bin/ld: RenderTarget.cpp:(.text+0x863): undefined reference to `glMatrixMode'
/usr/bin/ld: RenderTarget.cpp:(.text+0x868): undefined reference to `glPopMatrix'
/usr/bin/ld: RenderTarget.cpp:(.text+0x872): undefined reference to `glMatrixMode'
/usr/bin/ld: RenderTarget.cpp:(.text+0x877): undefined reference to `glPopMatrix'
/usr/bin/ld: RenderTarget.cpp:(.text+0x87c): undefined reference to `glPopClientAttrib'
/usr/bin/ld: /home/uzzer/LIB/SFML-2.5.1/lib/libsfml-graphics-s.a(RenderTarget.cpp.o): in function `sf::RenderTarget::initialize()':
RenderTarget.cpp:(.text+0x9c3): undefined reference to `sf::Lock::Lock(sf::Mutex&)'
/usr/bin/ld: RenderTarget.cpp:(.text+0x9de): undefined reference to `sf::Lock::~Lock()'
/usr/bin/ld: /home/uzzer/LIB/SFML-2.5.1/lib/libsfml-graphics-s.a(RenderTarget.cpp.o): in function `sf::RenderTarget::applyCurrentView()':
RenderTarget.cpp:(.text+0xa60): undefined reference to `glViewport'
/usr/bin/ld: RenderTarget.cpp:(.text+0xa6a): undefined reference to `glMatrixMode'
/usr/bin/ld: RenderTarget.cpp:(.text+0xa82): undefined reference to `glLoadMatrixf'
/usr/bin/ld: RenderTarget.cpp:(.text+0xa8c): undefined reference to `glMatrixMode'
/usr/bin/ld: /home/uzzer/LIB/SFML-2.5.1/lib/libsfml-graphics-s.a(RenderTarget.cpp.o): in function `sf::RenderTarget::applyBlendMode(sf::BlendMode const&)':
RenderTarget.cpp:(.text+0xbb0): undefined reference to `glBlendFunc'
/usr/bin/ld: RenderTarget.cpp:(.text+0xc19): undefined reference to `sf::err()'
/usr/bin/ld: RenderTarget.cpp:(.text+0xc6e): undefined reference to `sf::err()'
/usr/bin/ld: RenderTarget.cpp:(.text+0xcc3): undefined reference to `sf::err()'
/usr/bin/ld: /home/uzzer/LIB/SFML-2.5.1/lib/libsfml-graphics-s.a(RenderTarget.cpp.o): in function `sf::RenderTarget::resetGLStates()':
RenderTarget.cpp:(.text+0xf80): undefined reference to `glDisable'
/usr/bin/ld: RenderTarget.cpp:(.text+0xf8a): undefined reference to `glDisable'
/usr/bin/ld: RenderTarget.cpp:(.text+0xf94): undefined reference to `glDisable'
/usr/bin/ld: RenderTarget.cpp:(.text+0xf9e): undefined reference to `glDisable'
/usr/bin/ld: RenderTarget.cpp:(.text+0xfa8): undefined reference to `glEnable'
/usr/bin/ld: RenderTarget.cpp:(.text+0xfb2): undefined reference to `glEnable'
/usr/bin/ld: RenderTarget.cpp:(.text+0xfbc): undefined reference to `glMatrixMode'
/usr/bin/ld: RenderTarget.cpp:(.text+0xfc1): undefined reference to `glLoadIdentity'
/usr/bin/ld: RenderTarget.cpp:(.text+0xfcb): undefined reference to `glEnableClientState'
/usr/bin/ld: RenderTarget.cpp:(.text+0xfd5): undefined reference to `glEnableClientState'
/usr/bin/ld: RenderTarget.cpp:(.text+0xfdf): undefined reference to `glEnableClientState'
/usr/bin/ld: /home/uzzer/LIB/SFML-2.5.1/lib/libsfml-graphics-s.a(RenderTarget.cpp.o): in function `sf::RenderTarget::pushGLStates()':
RenderTarget.cpp:(.text+0x1104): undefined reference to `glPushClientAttrib'
/usr/bin/ld: RenderTarget.cpp:(.text+0x110e): undefined reference to `glPushAttrib'
/usr/bin/ld: RenderTarget.cpp:(.text+0x1118): undefined reference to `glMatrixMode'
/usr/bin/ld: RenderTarget.cpp:(.text+0x111d): undefined reference to `glPushMatrix'
/usr/bin/ld: RenderTarget.cpp:(.text+0x1127): undefined reference to `glMatrixMode'
/usr/bin/ld: RenderTarget.cpp:(.text+0x112c): undefined reference to `glPushMatrix'
/usr/bin/ld: RenderTarget.cpp:(.text+0x1136): undefined reference to `glMatrixMode'
/usr/bin/ld: RenderTarget.cpp:(.text+0x113b): undefined reference to `glPushMatrix'
/usr/bin/ld: /home/uzzer/LIB/SFML-2.5.1/lib/libsfml-graphics-s.a(RenderTarget.cpp.o): in function `sf::RenderTarget::setupDraw(bool, sf::RenderStates const&)':
.............etc
/usr/bin/ld: GLExtensions.cpp:(.text+0xa1): undefined reference to `sf::err()'
/usr/bin/ld: GLExtensions.cpp:(.text+0xf8): undefined reference to `sf::err()'
/usr/bin/ld: GLExtensions.cpp:(.text+0x15e): undefined reference to `glGetString'
/usr/bin/ld: /home/uzzer/LIB/SFML-2.5.1/lib/libsfml-graphics-s.a(Image.cpp.o): in function `sf::Image::getPixelsPtr() const':
Image.cpp:(.text+0x778): undefined reference to `sf::err()'
collect2: error: ld returned 1 exit status
gcc version 10.2.0 (Ubuntu 10.2.0-13ubuntu1).
$g++ -v -print-search-dirs
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/10/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none:amdgcn-amdhsa:hsa
OFFLOAD_TARGET_DEFAULT=1
install: /usr/lib/gcc/x86_64-linux-gnu/10/
programs: =/usr/lib/gcc/x86_64-linux-gnu/10/:/usr/lib/gcc/x86_64-linux-gnu/10/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/10/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/10/../../../../x86_64-linux-gnu/bin/x86_64-linux-gnu/10/:/usr/lib/gcc/x86_64-linux-gnu/10/../../../../x86_64-linux-gnu/bin/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/10/../../../../x86_64-linux-gnu/bin/
libraries: =/usr/lib/gcc/x86_64-linux-gnu/10/:/usr/lib/gcc/x86_64-linux-gnu/10/../../../../x86_64-linux-gnu/lib/x86_64-linux-gnu/10/:/usr/lib/gcc/x86_64-linux-gnu/10/../../../../x86_64-linux-gnu/lib/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/10/../../../../x86_64-linux-gnu/lib/../lib/:/usr/lib/gcc/x86_64-linux-gnu/10/../../../x86_64-linux-gnu/10/:/usr/lib/gcc/x86_64-linux-gnu/10/../../../x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/10/../../../../lib/:/lib/x86_64-linux-gnu/10/:/lib/x86_64-linux-gnu/:/lib/../lib/:/usr/lib/x86_64-linux-gnu/10/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-linux-gnu/10/../../../../x86_64-linux-gnu/lib/:/usr/lib/gcc/x86_64-linux-gnu/10/../../../:/lib/:/usr/lib/
What am I doing wrong / stupid?
The order of libraries on the command line is important - this means that a library containing the definition of a function should appear after any source files or object files which use it. Please see here for more information. Also the comment of #SeanFrancisNBallais is exactly about that.
In your case you need to place the sfml-system-s library after all other SFML libraries, something like below:
g++ <...other options...> -lsfml-graphics-s -lsfml-window-s -lsfml-system-s -lGLU -lGL -lX11 -ludev -lpthread
Also, from this line you can see that the GL library uses the X11 library (not vise versa) and so on. Some basic GCC libraries, such as stdc++ or m, aren't to be present on the command line - they are here by default.
I am running an OpenGL C++ file with fragment and vertex files.
I am on Ubuntu 18.04.
The problem is that when I link with g++ command I get errors :
my first linking command was :
g++ -o proj prog.cpp -lGL -lm
and I am getting these errors :
/tmp/ccdaDttM.o: In function `main':
prog.cpp:(.text+0x18): undefined reference to `glfwInit'
prog.cpp:(.text+0x27): undefined reference to `glfwWindowHint'
prog.cpp:(.text+0x36): undefined reference to `glfwWindowHint'
prog.cpp:(.text+0x45): undefined reference to `glfwWindowHint'
prog.cpp:(.text+0x54): undefined reference to `glfwWindowHint'
prog.cpp:(.text+0x63): undefined reference to `glfwWindowHint'
prog.cpp:(.text+0x84): undefined reference to `glfwCreateWindow'
prog.cpp:(.text+0x9f): undefined reference to `glfwGetFramebufferSize'
prog.cpp:(.text+0xd3): undefined reference to `glfwTerminate'
prog.cpp:(.text+0xe9): undefined reference to `glfwMakeContextCurrent'
prog.cpp:(.text+0xef): undefined reference to `glewExperimental'
prog.cpp:(.text+0xf5): undefined reference to `glewInit'
prog.cpp:(.text+0x22c): undefined reference to `__glewGenVertexArrays'
prog.cpp:(.text+0x241): undefined reference to `__glewGenBuffers'
prog.cpp:(.text+0x256): undefined reference to `__glewBindVertexArray'
prog.cpp:(.text+0x264): undefined reference to `__glewBindBuffer'
prog.cpp:(.text+0x277): undefined reference to `__glewBufferData'
prog.cpp:(.text+0x293): undefined reference to `__glewVertexAttribPointer'
prog.cpp:(.text+0x2bc): undefined reference to `__glewEnableVertexAttribArray'
prog.cpp:(.text+0x2ca): undefined reference to `__glewVertexAttribPointer'
prog.cpp:(.text+0x2f3): undefined reference to `__glewEnableVertexAttribArray'
prog.cpp:(.text+0x301): undefined reference to `__glewBindVertexArray'
prog.cpp:(.text+0x314): undefined reference to `glfwWindowShouldClose'
prog.cpp:(.text+0x326): undefined reference to `glfwPollEvents'
prog.cpp:(.text+0x368): undefined reference to `__glewBindVertexArray'
prog.cpp:(.text+0x38a): undefined reference to `__glewBindVertexArray'
prog.cpp:(.text+0x39d): undefined reference to `glfwSwapBuffers'
prog.cpp:(.text+0x3a9): undefined reference to `__glewDeleteVertexArrays'
prog.cpp:(.text+0x3be): undefined reference to `__glewDeleteBuffers'
prog.cpp:(.text+0x3d1): undefined reference to `glfwTerminate'
/tmp/ccdaDttM.o: In function `Shader::Shader(char const*, char const*)':
prog.cpp:(.text._ZN6ShaderC2EPKcS1_[_ZN6ShaderC5EPKcS1_]+0x27b): undefined reference to `__glewCreateShader'
prog.cpp:(.text._ZN6ShaderC2EPKcS1_[_ZN6ShaderC5EPKcS1_]+0x28f): undefined reference to `__glewShaderSource'
prog.cpp:(.text._ZN6ShaderC2EPKcS1_[_ZN6ShaderC5EPKcS1_]+0x2af): undefined reference to `__glewCompileShader'
prog.cpp:(.text._ZN6ShaderC2EPKcS1_[_ZN6ShaderC5EPKcS1_]+0x2c0): undefined reference to `__glewGetShaderiv'
prog.cpp:(.text._ZN6ShaderC2EPKcS1_[_ZN6ShaderC5EPKcS1_]+0x2e7): undefined reference to `__glewGetShaderInfoLog'
prog.cpp:(.text._ZN6ShaderC2EPKcS1_[_ZN6ShaderC5EPKcS1_]+0x347): undefined reference to `__glewCreateShader'
prog.cpp:(.text._ZN6ShaderC2EPKcS1_[_ZN6ShaderC5EPKcS1_]+0x35b): undefined reference to `__glewShaderSource'
prog.cpp:(.text._ZN6ShaderC2EPKcS1_[_ZN6ShaderC5EPKcS1_]+0x37b): undefined reference to `__glewCompileShader'
prog.cpp:(.text._ZN6ShaderC2EPKcS1_[_ZN6ShaderC5EPKcS1_]+0x38c): undefined reference to `__glewGetShaderiv'
prog.cpp:(.text._ZN6ShaderC2EPKcS1_[_ZN6ShaderC5EPKcS1_]+0x3b3): undefined reference to `__glewGetShaderInfoLog'
prog.cpp:(.text._ZN6ShaderC2EPKcS1_[_ZN6ShaderC5EPKcS1_]+0x413): undefined reference to `__glewCreateProgram'
prog.cpp:(.text._ZN6ShaderC2EPKcS1_[_ZN6ShaderC5EPKcS1_]+0x427): undefined reference to `__glewAttachShader'
prog.cpp:(.text._ZN6ShaderC2EPKcS1_[_ZN6ShaderC5EPKcS1_]+0x443): undefined reference to `__glewAttachShader'
prog.cpp:(.text._ZN6ShaderC2EPKcS1_[_ZN6ShaderC5EPKcS1_]+0x45f): undefined reference to `__glewLinkProgram'
prog.cpp:(.text._ZN6ShaderC2EPKcS1_[_ZN6ShaderC5EPKcS1_]+0x473): undefined reference to `__glewGetProgramiv'
prog.cpp:(.text._ZN6ShaderC2EPKcS1_[_ZN6ShaderC5EPKcS1_]+0x49d): undefined reference to `__glewGetProgramInfoLog'
prog.cpp:(.text._ZN6ShaderC2EPKcS1_[_ZN6ShaderC5EPKcS1_]+0x500): undefined reference to `__glewDeleteShader'
prog.cpp:(.text._ZN6ShaderC2EPKcS1_[_ZN6ShaderC5EPKcS1_]+0x511): undefined reference to `__glewDeleteShader'
/tmp/ccdaDttM.o: In function `Shader::Use()':
prog.cpp:(.text._ZN6Shader3UseEv[_ZN6Shader3UseEv]+0xf): undefined reference to `__glewUseProgram'
collect2: error: ld returned 1 exit status
When I googled, I found this post : undefined reference to `__glewCreateShader`
and according to the post, I changed the command to :
g++ -o proj prog.cpp -lGLEW -lm
The long list of errors is reduced but still :
/usr/bin/ld: /tmp/ccSaE0MX.o: undefined reference to symbol 'glDrawArrays'
//usr/lib/x86_64-linux-gnu/libGL.so.1: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
I viewed several posts and they almost say the same thing
OpenGL library not linking
The command I tried :
g++ -o proj prog.cpp -lGLEW -lm -lGLU -lglut
g++ -o proj prog.cpp -lGL -lGLEW -lm
g++ -o proj prog.cpp -lGLEW -lGL -lm
g++ -o proj prog.cpp -lGLEW -lopengl32 -lm
g++ prog.cpp -lGL -lGLU -lGLEW -lGLFW -lm
g++ prog.cpp -lGL -lGLU -lGLEW -lglut -lm -o proj
include :
#include <iostream>
#define GLEW_STATIC
#include <GL/glew.h>
#include <GLFW/glfw3.h>
#include "Shader.h"
Update :
here is what I am getting now
g++ -o proj sample.cpp libglut.a -lGL -lm
/usr/bin/ld: libglut.a(glut_event.o): undefined reference to symbol 'XWithdrawWindow'
//usr/lib/x86_64-linux-gnu/libX11.so.6: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
Please tell me what am I doing wrong.
Thanks
I have been running through a few tutorials of boost and the libraries it has.
I ran through the basic tutorial for boost:
http://www.boost.org/doc/libs/1_52_0/more/getting_started/unix-variants.html
and it worked fine. I am having issues with the asio tutorial:
http://www.boost.org/doc/libs/1_50_0/doc/html/boost_asio/tutorial/tutdaytime1/src.html
It looks like linking errors, but I am including the same path as before:
g++ -I /usr/local/boost_1_52_0 test.cpp -o example
Error:
/tmp/cce4EZME.o: In function `__static_initialization_and_destruction_0(int, int)':
test.cpp:(.text+0x57b): undefined reference to `boost::system::generic_category()'
test.cpp:(.text+0x587): undefined reference to `boost::system::generic_category()'
test.cpp:(.text+0x593): undefined reference to `boost::system::system_category()'
/tmp/cce4EZME.o: In function `boost::system::error_code::error_code()':
test.cpp:(.text._ZN5boost6system10error_codeC2Ev[_ZN5boost6system10error_codeC5Ev]+0x17): undefined reference to `boost::system::system_category()'
/tmp/cce4EZME.o: In function `boost::asio::error::get_system_category()':
test.cpp:(.text._ZN5boost4asio5error19get_system_categoryEv[_ZN5boost4asio5error19get_system_categoryEv]+0x5): undefined reference to `boost::system::system_category()'
/tmp/cce4EZME.o: In function `boost::asio::detail::posix_thread::~posix_thread()':
test.cpp:(.text._ZN5boost4asio6detail12posix_threadD2Ev[_ZN5boost4asio6detail12posix_threadD5Ev]+0x26): undefined reference to `pthread_detach'
/tmp/cce4EZME.o: In function `boost::asio::detail::posix_thread::join()':
test.cpp:(.text._ZN5boost4asio6detail12posix_thread4joinEv[_ZN5boost4asio6detail12posix_thread4joinEv]+0x2b): undefined reference to `pthread_join'
/tmp/cce4EZME.o: In function `boost::asio::detail::posix_thread::start_thread(boost::asio::detail::posix_thread::func_base*)':
test.cpp:(.text._ZN5boost4asio6detail12posix_thread12start_threadEPNS2_9func_baseE[_ZN5boost4asio6detail12posix_thread12start_threadEPNS2_9func_baseE]+0x29): undefined reference to `pthread_create'
collect2: error: ld returned 1 exit status
assuming you have installed your boost libraries in your /usr/lib directory and boost header files in /usr/include/boost and you have saved your code in a file named daytime1.cpp, you have to use the following command to compile the source code you have linked to:
$ g++ daytime1.cpp -o daytime -L /usr/lib/ -lboost_system -lboost_thread -lpthread