I am trying to build gRPC in C++ by following c++ gRPC installation. My OS is Ubuntu20.4 LTS installed on Raspberry Pi 4.
When I typed this command "make -j"
$ cd grpc
$ mkdir -p cmake/build
$ pushd cmake/build
$ cmake -DgRPC_INSTALL=ON \
-DgRPC_BUILD_TESTS=OFF \
-DCMAKE_INSTALL_PREFIX=$MY_INSTALL_DIR \
../..
$ make -j
this error occurs.
[ 1%] Built target zlibstatic
・
・
[ 97%] Built target mimics_pcre_test
[ 97%] Built target possible_match_test
[ 97%] Built target set_test
[ 97%] Built target regexp_test
[ 97%] Built target search_test
[ 97%] Linking CXX executable bssl
/usr/bin/ld: CMakeFiles/bssl.dir/src/tool/transport_common.cc.o: in function `PrintConnectionInfo(bio_st*, ssl_st const*)':
transport_common.cc:(.text+0xd40): undefined reference to `X509_NAME_print_ex'
/usr/bin/ld: transport_common.cc:(.text+0xd74): undefined reference to `X509_NAME_print_ex'
/usr/bin/ld: libcrypto.a(trust_token.c.o):(.data.rel.ro+0x50): undefined reference to `voprf_exp2_generate_key'
/usr/bin/ld: libcrypto.a(trust_token.c.o):(.data.rel.ro+0x58): undefined reference to `voprf_exp2_client_key_from_bytes'
/usr/bin/ld: libcrypto.a(trust_token.c.o):(.data.rel.ro+0x60): undefined reference to `voprf_exp2_issuer_key_from_bytes'
/usr/bin/ld: libcrypto.a(trust_token.c.o):(.data.rel.ro+0x68): undefined reference to `voprf_exp2_blind'
/usr/bin/ld: libcrypto.a(trust_token.c.o):(.data.rel.ro+0x70): undefined reference to `voprf_exp2_sign'
/usr/bin/ld: libcrypto.a(trust_token.c.o):(.data.rel.ro+0x78): undefined reference to `voprf_exp2_unblind'
/usr/bin/ld: libcrypto.a(trust_token.c.o):(.data.rel.ro+0x80): undefined reference to `voprf_exp2_read'
/usr/bin/ld: libcrypto.a(x509_vfy.c.o): in function `reject_dns_name_in_common_name':
x509_vfy.c:(.text+0x16dc): undefined reference to `ASN1_STRING_to_UTF8'
/usr/bin/ld: libcrypto.a(x_name.c.o): in function `asn1_string_canon':
x_name.c:(.text+0xe94): undefined reference to `ASN1_STRING_to_UTF8'
/usr/bin/ld: libcrypto.a(v3_crld.c.o): in function `print_distpoint':
v3_crld.c:(.text+0x1304): undefined reference to `X509_NAME_print_ex'
/usr/bin/ld: libcrypto.a(v3_utl.c.o): in function `do_check_string':
v3_utl.c:(.text+0x288c): undefined reference to `ASN1_STRING_to_UTF8'
/usr/bin/ld: libcrypto.a(algorithm.c.o): in function `x509_digest_sign_algorithm':
algorithm.c:(.text+0xac): undefined reference to `x509_rsa_ctx_to_pss'
/usr/bin/ld: libcrypto.a(algorithm.c.o): in function `x509_digest_verify_init':
algorithm.c:(.text+0x2c4): undefined reference to `x509_rsa_pss_to_ctx'
/usr/bin/ld: libcrypto.a(v3_alt.c.o): in function `GENERAL_NAME_print':
v3_alt.c:(.text+0x7c4): undefined reference to `X509_NAME_print_ex'
/usr/bin/ld: libcrypto.a(t_x509.c.o): in function `X509_print_ex':
t_x509.c:(.text+0x404): undefined reference to `X509_NAME_print_ex'
/usr/bin/ld: t_x509.c:(.text+0x52c): undefined reference to `X509_NAME_print_ex'
/usr/bin/ld: libcrypto.a(t_x509.c.o): in function `X509_signature_print':
t_x509.c:(.text+0xb7c): undefined reference to `x509_print_rsa_pss_params'
collect2: error: ld returned 1 exit status
make[2]: *** [third_party/boringssl-with-bazel/CMakeFiles/bssl.dir/build.make:339: third_party/boringssl-with-bazel/bssl] Error 1
make[1]: *** [CMakeFiles/Makefile2:4800: third_party/boringssl-with-bazel/CMakeFiles/bssl.dir/all] Error 2
make: *** [Makefile:136: all] Error 2
Please help me to fix this problem.
Can you show what value the gRPC_SSL_PROVIDER variable has? If has module than you just init submodules and build with BoringSSL (see and see). Another option, you can build with OpenSSL, just set -DgRPC_SSL_PROVIDER=package.
I'm trying to compile and run the qml-sink example which is provided inside the gstreamer-good-plugin (QT Example). But currently I get a lot of undefined reference errors during the compile time. It seems that the linker does not link the libraries correctly.
I have checked the list of linked libraries and from my point of view all needed libs are listed.
E.g. gst_object_ref, gst_init, ... are undefined.
My setup:
Windows 10
Qt 5.11
Gstreamer 1.0
Gstremer devel 1.0
Gstreamer plugin good
Installed GStreamer version from here: GStreamer Download => gstreamer-1.0-devel-x86_64-1.14.3.msi and gstreamer-1.0-x86_64-1.14.3.msi
Can anyone please help me, how I can solve this problem?
Errortrace:
"C:\Program Files\CMake\bin\cmake.exe" --build . --target all
"C:\Program Files\CMake\bin\cmake.exe" -HC:\gst-plugins-good-1.14.4\tests\examples\qt\qmlsink -BC:\gst-plugins-good-1.14.4\tests\examples\qt\build-qmlsink-Desktop_Qt_5_11_1_MinGW_32bit-Vorgabe --check-build-system CMakeFiles\Makefile.cmake 0
"C:\Program Files\CMake\bin\cmake.exe" -E cmake_progress_start C:\gst-plugins-good-1.14.4\tests\examples\qt\build-qmlsink-Desktop_Qt_5_11_1_MinGW_32bit-Vorgabe\CMakeFiles C:\gst-plugins-good-1.14.4\tests\examples\qt\build-qmlsink-Desktop_Qt_5_11_1_MinGW_32bit-Vorgabe\CMakeFiles\progress.marks
D:/Qt/Tools/mingw530_32/bin/mingw32-make.exe -f CMakeFiles\Makefile2 all
mingw32-make.exe[1]: Entering directory 'C:/gst-plugins-good-1.14.4/tests/examples/qt/build-qmlsink-Desktop_Qt_5_11_1_MinGW_32bit-Vorgabe'
D:/Qt/Tools/mingw530_32/bin/mingw32-make.exe -f CMakeFiles\qml-example.dir\build.make CMakeFiles/qml-example.dir/depend
mingw32-make.exe[2]: Entering directory 'C:/gst-plugins-good-1.14.4/tests/examples/qt/build-qmlsink-Desktop_Qt_5_11_1_MinGW_32bit-Vorgabe'
"C:\Program Files\CMake\bin\cmake.exe" -E cmake_depends "MinGW Makefiles"
C:\gst-plugins-good-1.14.4\tests\examples\qt\qmlsink C:\gst-plugins-good-1.14.4\tests\examples\qt\qmlsink C:\gst-plugins-good-1.14.4\tests\examples\qt\build-qmlsink-Desktop_Qt_5_11_1_MinGW_32bit-Vorgabe
C:\gst-plugins-good-1.14.4\tests\examples\qt\build-qmlsink-Desktop_Qt_5_11_1_MinGW_32bit-Vorgabe C:\gst-plugins-good-1.14.4\tests\examples\qt\build-qmlsink-Desktop_Qt_5_11_1_MinGW_32bit-Vorgabe\CMakeFiles\qml-example.dir\DependInfo.cmake --color=
mingw32-make.exe[2]: Leaving directory 'C:/gst-plugins-good-1.14.4/tests/examples/qt/build-qmlsink-Desktop_Qt_5_11_1_MinGW_32bit-Vorgabe'
D:/Qt/Tools/mingw530_32/bin/mingw32-make.exe -f CMakeFiles\qml-example.dir\build.make CMakeFiles/qml-example.dir/build
mingw32-make.exe[2]: Entering directory 'C:/gst-plugins-good-1.14.4/tests/examples/qt/build-qmlsink-Desktop_Qt_5_11_1_MinGW_32bit-Vorgabe'
[ 25%] Linking CXX executable qml-example.exe
"C:\Program Files\CMake\bin\cmake.exe" -E cmake_link_script CMakeFiles\qml-example.dir\link.txt --verbose=1
"C:\Program Files\CMake\bin\cmake.exe" -E remove -f CMakeFiles\qml-example.dir/objects.a
D:\Qt\Tools\mingw530_32\bin\ar.exe cr CMakeFiles\qml-example.dir/objects.a #CMakeFiles\qml-example.dir\objects1.rsp
D:\Qt\Tools\mingw530_32\bin\g++.exe -Wl,--whole-archive CMakeFiles\qml-example.dir/objects.a -Wl,--no-whole-archive -o qml-example.exe -Wl,--out-implib,libqml-example.dll.a -Wl,--major-image-version,0,--minor-image-version,0
#CMakeFiles\qml-example.dir\linklibs.rsp
CMakeFiles\qml-example.dir/objects.a(main.cpp.obj):main.cpp:(.text+0x2b): undefined reference to `gst_object_ref'
CMakeFiles\qml-example.dir/objects.a(main.cpp.obj):main.cpp:(.text+0x87): undefined reference to `gst_object_unref'
CMakeFiles\qml-example.dir/objects.a(main.cpp.obj):main.cpp:(.text+0xa7): undefined reference to `operator delete(void*)'
CMakeFiles\qml-example.dir/objects.a(main.cpp.obj):main.cpp:(.text+0xc8): undefined reference to `operator delete(void*)'
CMakeFiles\qml-example.dir/objects.a(main.cpp.obj):main.cpp:(.text+0xf3): undefined reference to `gst_element_set_state'
CMakeFiles\qml-example.dir/objects.a(main.cpp.obj):main.cpp:(.text+0x150): undefined reference to `gst_init'
CMakeFiles\qml-example.dir/objects.a(main.cpp.obj):main.cpp:(.text+0x17d): undefined reference to `gst_pipeline_new'
CMakeFiles\qml-example.dir/objects.a(main.cpp.obj):main.cpp:(.text+0x194): undefined reference to `gst_element_factory_make'
CMakeFiles\qml-example.dir/objects.a(main.cpp.obj):main.cpp:(.text+0x1ab): undefined reference to `gst_element_factory_make'
CMakeFiles\qml-example.dir/objects.a(main.cpp.obj):main.cpp:(.text+0x1c2): undefined reference to `gst_element_factory_make'
CMakeFiles\qml-example.dir/objects.a(main.cpp.obj):main.cpp:(.text+0x203): undefined reference to `g_assertion_message_expr'
CMakeFiles\qml-example.dir/objects.a(main.cpp.obj):main.cpp:(.text+0x208): undefined reference to `gst_bin_get_type'
CMakeFiles\qml-example.dir/objects.a(main.cpp.obj):main.cpp:(.text+0x217): undefined reference to `g_type_check_instance_cast'
CMakeFiles\qml-example.dir/objects.a(main.cpp.obj):main.cpp:(.text+0x23e): undefined reference to `gst_bin_add_many'
CMakeFiles\qml-example.dir/objects.a(main.cpp.obj):main.cpp:(.text+0x25f): undefined reference to `gst_element_link_many'
CMakeFiles\qml-example.dir/objects.a(main.cpp.obj):main.cpp:(.text+0x37f): undefined reference to `g_assertion_message_expr'
CMakeFiles\qml-example.dir/objects.a(main.cpp.obj):main.cpp:(.text+0x3a1): undefined reference to `g_object_set'
CMakeFiles\qml-example.dir/objects.a(main.cpp.obj):main.cpp:(.text+0x3ad): undefined reference to `operator new(unsigned int)'
CMakeFiles\qml-example.dir/objects.a(main.cpp.obj):main.cpp:(.text+0x3f6): undefined reference to `gst_element_set_state'
CMakeFiles\qml-example.dir/objects.a(main.cpp.obj):main.cpp:(.text+0x401): undefined reference to `gst_object_unref'
CMakeFiles\qml-example.dir/objects.a(main.cpp.obj):main.cpp:(.text+0x41e): undefined reference to `gst_deinit'
CMakeFiles\qml-example.dir/objects.a(main.cpp.obj):main.cpp:(.text+0x467): undefined reference to `operator delete(void*)'
CMakeFiles\qml-example.dir/objects.a(main.cpp.obj):main.cpp:(.text$_ZN5QListIP7QObjectE13detach_helperEi[__ZN5QListIP7QObjectE13detach_helperEi]+0x8c): undefined reference to `__cxa_begin_catch'
CMakeFiles\qml-example.dir/objects.a(main.cpp.obj):main.cpp:(.text$_ZN5QListIP7QObjectE13detach_helperEi[__ZN5QListIP7QObjectE13detach_helperEi]+0xa3): undefined reference to `__cxa_rethrow'
CMakeFiles\qml-example.dir/objects.a(main.cpp.obj):main.cpp:(.text$_ZN5QListIP7QObjectE13detach_helperEi[__ZN5QListIP7QObjectE13detach_helperEi]+0xaa): undefined reference to `__cxa_end_catch'
CMakeFiles\qml-example.dir/objects.a(main.cpp.obj):main.cpp:(.rdata$_ZTI10SetPlaying[__ZTI10SetPlaying]+0x0): undefined reference to `vtable for __cxxabiv1::__si_class_type_info'
CMakeFiles\qml-example.dir/objects.a(main.cpp.obj):main.cpp:(.rdata$_ZTI9QRunnable[__ZTI9QRunnable]+0x0): undefined reference to `vtable for __cxxabiv1::__class_type_info'
CMakeFiles\qml-example.dir/objects.a(main.cpp.obj):main.cpp:(.eh_frame+0x13): undefined reference to `__gxx_personality_v0'
CMakeFiles\qml-example.dir/objects.a(main.cpp.obj):main.cpp:(.eh_frame$_ZN5QListIP7QObjectED1Ev+0x13): undefined reference to `__gxx_personality_v0'
CMakeFiles\qml-example.dir/objects.a(main.cpp.obj):main.cpp:(.eh_frame$_ZN5QListIP7QObjectE13detach_helperEi+0x13): undefined reference to `__gxx_personality_v0'
CMakeFiles\qml-example.dir/objects.a(qrc_qml.cpp.obj):qrc_qml.cpp:(.eh_frame+0x8b): undefined reference to `__gxx_personality_v0'
collect2.exe: error: ld returned 1 exit status
mingw32-make.exe[2]: *** [qml-example.exe] Error 1
mingw32-make.exe[1]: *** [CMakeFiles/qml-example.dir/all] Error 2
CMakeFiles\qml-example.dir\build.make:112: recipe for target 'qml-example.exe' failed
mingw32-make.exe[2]: Leaving directory 'C:/gst-plugins-good-1.14.4/tests/examples/qt/build-qmlsink-Desktop_Qt_5_11_1_MinGW_32bit-Vorgabe'
CMakeFiles\Makefile2:66: recipe for target 'CMakeFiles/qml-example.dir/all' failed
mingw32-make.exe[1]: Leaving directory 'C:/gst-plugins-good-1.14.4/tests/examples/qt/build-qmlsink-Desktop_Qt_5_11_1_MinGW_32bit-Vorgabe'
Makefile:82: recipe for target 'all' failed
mingw32-make.exe: *** [all] Error 2
It looks like you're building for windows. The only way I've compiled the qml plugin on windows is using qmake using the provided .pro file. My experiments with compiling using the mingw toolchain provided by Qt were unsuccessful due to mismatching C++ ABI's between GStreamer and Qt. I ended up using MSVC/Visual Studio for compiling instead.
The undefined references to g_/gst_ probably means you don't have pkg-config setup correctly on your system. pkg-config.exe --modversion gstreamer-1.0 Should output the version of GStreamer you installed.
Where did you download GStreamer from? What GStreamer version exactly? Did you download binaries or did you compile it yourself?
I have a project I want to build with CMake and compile with MinGW. The project uses Zlib. When I build with CMake I get no errors but then when I run MinGW Make it gives the following output:
C:\Projects\MultiMCBuild>C:\Qt\Tools\mingw492_32\bin\mingw32-make.exe
.
.
.
[ 50%] Linking CXX shared library ..\libMultiMC_logic.dll
C:/Projects/MultiMCBuild/External/Install/QuaZIP/lib/libquazip.a(unzip.c.obj):unzip.c:(.text+0x1f6c): undefined reference to 'z_inflateEnd'
C:/Projects/MultiMCBuild/External/Install/QuaZIP/lib/libquazip.a(unzip.c.obj):unzip.c:(.text+0x29e2): undefined reference to 'z_inflateInit2_'
C:/Projects/MultiMCBuild/External/Install/QuaZIP/lib/libquazip.a(unzip.c.obj):unzip.c:(.text+0x2a6d): undefined reference to 'z_get_crc_table'
C:/Projects/MultiMCBuild/External/Install/QuaZIP/lib/libquazip.a(unzip.c.obj):unzip.c:(.text+0x2ca7): undefined reference to 'z_inflateEnd'
C:/Projects/MultiMCBuild/External/Install/QuaZIP/lib/libquazip.a(unzip.c.obj):unzip.c:(.text+0x2f52): undefined reference to 'z_inflateInit2_'
C:/Projects/MultiMCBuild/External/Install/QuaZIP/lib/libquazip.a(unzip.c.obj):unzip.c:(.text+0x2f77): undefined reference to 'z_inflateEnd'
C:/Projects/MultiMCBuild/External/Install/QuaZIP/lib/libquazip.a(unzip.c.obj):unzip.c:(.text+0x3239): undefined reference to 'z_inflateInit2_'
C:/Projects/MultiMCBuild/External/Install/QuaZIP/lib/libquazip.a(unzip.c.obj):unzip.c:(.text+0x3317): undefined reference to 'z_inflateEnd'
C:/Projects/MultiMCBuild/External/Install/QuaZIP/lib/libquazip.a(unzip.c.obj):unzip.c:(.text+0x3626): undefined reference to 'z_crc32'
C:/Projects/MultiMCBuild/External/Install/QuaZIP/lib/libquazip.a(unzip.c.obj):unzip.c:(.text+0x371f): undefined reference to 'z_inflate'
C:/Projects/MultiMCBuild/External/Install/QuaZIP/lib/libquazip.a(unzip.c.obj):unzip.c:(.text+0x376a): undefined reference to 'z_crc32'
C:/Projects/MultiMCBuild/External/Install/QuaZIP/lib/libquazip.a(unzip.c.obj):unzip.c:(.text+0x3a57): undefined reference to 'z_inflateEnd'
C:/Qt/Tools/mingw492_32/bin/../lib/gcc/i686-w64- mingw32/4.9.2/../../../../i686-w64-mingw32/bin/ld.exe: C:/Projects/MultiMCBuild/External/Install/QuaZIP/lib/libquazip.a(unzip.c.obj): bad reloc address 0x20 in section `.eh_frame'
collect2.exe: error: ld returned 1 exit status
logic\CMakeFiles\MultiMC_logic.dir\build.make:3186: recipe for target 'libMultiMC_logic.dll' failed
mingw32-make[2]: * * * [libMultiMC_logic.dll] Error 1
CMakeFiles\Makefile2:1806: recipe for target 'logic/CMakeFiles/MultiMC_logic.dir/all' failed
mingw32-make[1]: * * * [logic/CMakeFiles/MultiMC_logic.dir/all] Error 2
makefile:159: recipe for target 'all' failed
mingw32-make: * * * [all] Error 2
Anyone have a clue what I can do to fix this? I read that the code can't find the ZLib library, how do I link it?
EDIT here is my CMakeLists.txt. I got this from the Git project.
I just tried to generate a small example to reproduce your errors. I took my test file from the home page of zlib http://zlib.net/zpipe.c
My initial CMakeLists.txt was
cmake_minimum_required(VERSION 3.4)
project(zlib_test)
set(ZLIB_TEST_SOURCES zpipe.c)
add_executable(${PROJECT_NAME} ${ZLIB_TEST_SOURCES})
And I got the same errors
[ 50%] Building C object CMakeFiles/zlib_test.dir/zpipe.c.o
[100%] Linking C executable zlib_test
CMakeFiles/zlib_test.dir/zpipe.c.o: In function `def':
zpipe.c:(.text+0x65): undefined reference to `deflateInit_'
zpipe.c:(.text+0xcd): undefined reference to `deflateEnd'
zpipe.c:(.text+0x135): undefined reference to `deflate'
zpipe.c:(.text+0x1cf): undefined reference to `deflateEnd'
zpipe.c:(.text+0x25d): undefined reference to `deflateEnd'
CMakeFiles/zlib_test.dir/zpipe.c.o: In function `inf':
zpipe.c:(.text+0x2eb): undefined reference to `inflateInit_'
zpipe.c:(.text+0x353): undefined reference to `inflateEnd'
zpipe.c:(.text+0x3a4): undefined reference to `inflate'
zpipe.c:(.text+0x404): undefined reference to `inflateEnd'
zpipe.c:(.text+0x476): undefined reference to `inflateEnd'
zpipe.c:(.text+0x4a6): undefined reference to `inflateEnd'
collect2: error: ld returned 1 exit status
make[2]: *** [zlib_test] Error 1
make[1]: *** [CMakeFiles/zlib_test.dir/all] Error 2
make: *** [all] Error 2
After changing CMakeLists.txt to this form
cmake_minimum_required(VERSION 3.4)
project(zlib_test)
find_package(ZLIB REQUIRED)
if (ZLIB_FOUND)
include_directories(${ZLIB_INCLUDE_DIRS})
endif()
set(ZLIB_TEST_SOURCES zpipe.c)
add_executable(${PROJECT_NAME} ${ZLIB_TEST_SOURCES})
target_link_libraries(${PROJECT_NAME} ${ZLIB_LIBRARIES})
I could compile the program.
So your problem is: Where is ZLIB added in your CMakeLists.txt? At least, you need the line find_package(ZLIB REQUIRED).
I've just started working my way through the OpenGL SuperBible 6th ed and am having a very hard time getting any of the samples to compile on Ubuntu 14.04. I installed the dev packages dependencies:
sudo apt-get install xorg-dev libglu1-mesa-dev libglfw-dev nvidia-331-dev cmake
I grabbed gl3w from skaslev's github, ran the python script and then sudo copied gl3w.h and glcorearb.h to /usr/include/GL/
I grabbed the samples from the SuperBible github and the media files, unzipped the media files into bin/media. Then I went back to the root of the sb6 files (the folder is called sb6code_2013_11_10 in my case) where and ran:
cmake .
make
cmake works fine, but make throws:
[ 6%] Built target sb6
Linking CXX executable bin/alienrain
CMakeFiles/alienrain.dir/src/alienrain/alienrain.cpp.o: In function `sb6::application::run(sb6::application*)':
alienrain.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0x21): undefined reference to `glfwInit'
alienrain.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0x7a): undefined reference to `glfwOpenWindowHint'
alienrain.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0x90): undefined reference to `glfwOpenWindowHint'
alienrain.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0x9f): undefined reference to `glfwOpenWindowHint'
alienrain.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0xae): undefined reference to `glfwOpenWindowHint'
alienrain.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0xc4): undefined reference to `glfwOpenWindowHint'
CMakeFiles/alienrain.dir/src/alienrain/alienrain.cpp.o:alienrain.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0xee): more undefined references to `glfwOpenWindowHint' follow
CMakeFiles/alienrain.dir/src/alienrain/alienrain.cpp.o: In function `sb6::application::run(sb6::application*)':
alienrain.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0x12c): undefined reference to `glfwGetDesktopMode'
alienrain.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0x18e): undefined reference to `glfwOpenWindow'
alienrain.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0x1a8): undefined reference to `glfwSwapInterval'
alienrain.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0x1f2): undefined reference to `glfwOpenWindow'
alienrain.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0x22e): undefined reference to `glfwSetWindowTitle'
alienrain.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0x238): undefined reference to `glfwSetWindowSizeCallback'
alienrain.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0x242): undefined reference to `glfwSetKeyCallback'
alienrain.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0x24c): undefined reference to `glfwSetMouseButtonCallback'
alienrain.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0x256): undefined reference to `glfwSetMousePosCallback'
alienrain.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0x260): undefined reference to `glfwSetMouseWheelCallback'
alienrain.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0x277): undefined reference to `glfwEnable'
alienrain.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0x27e): undefined reference to `glfwDisable'
alienrain.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0x28f): undefined reference to `glfwGetWindowParam'
alienrain.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0x373): undefined reference to `glfwGetTime'
alienrain.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0x393): undefined reference to `glfwSwapBuffers'
alienrain.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0x39d): undefined reference to `glfwGetKey'
alienrain.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0x3bd): undefined reference to `glfwGetWindowParam'
alienrain.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0x3f5): undefined reference to `glfwTerminate'
lib/libsb6.a(gl3w.c.o): In function `open_libgl':
gl3w.c:(.text+0xf): undefined reference to `dlopen'
lib/libsb6.a(gl3w.c.o): In function `close_libgl':
gl3w.c:(.text+0x2b): undefined reference to `dlclose'
lib/libsb6.a(gl3w.c.o): In function `get_proc':
gl3w.c:(.text+0x45): undefined reference to `glXGetProcAddress'
gl3w.c:(.text+0x66): undefined reference to `dlsym'
collect2: error: ld returned 1 exit status
make[2]: *** [bin/alienrain] Error 1
make[1]: *** [CMakeFiles/alienrain.dir/all] Error 2
make: *** [all] Error 2
So I decided to try and write my own small program based on Listing 2.1 in the book:
#include "sb6.h"
class my_application : public sb6::application
{
void init()
{
static const char title[] = "OpenGL SuperBible - Listing 2.1";
sb6::application::init();
memcpy(info.title, title, sizeof(title));
}
void render(double currentTime)
{
static const GLfloat red[] = {1.0f, 0.0f, 0.0f, 1.0f};
glClearBufferfv(GL_COLOR, 0, red);
}
};
DECLARE_MAIN(my_application)
Then I try to compile it:
g++ listing2.1.cpp -o listing2.1 -lGL -lGLU -lX11 -lglfw -D_LINUX
But that gives me a different set of errors:
In file included from sb6.h:65:0,
from listing2.1.cpp:1:
GL/gl3w.h:546:8: error: ‘PFNGLGETNMAPDVARBPROC’ does not name a type
extern PFNGLGETNMAPDVARBPROC gl3wGetnMapdvARB;
^
GL/gl3w.h:547:8: error: ‘PFNGLGETNMAPFVARBPROC’ does not name a type
extern PFNGLGETNMAPFVARBPROC gl3wGetnMapfvARB;
^
GL/gl3w.h:548:8: error: ‘PFNGLGETNMAPIVARBPROC’ does not name a type
extern PFNGLGETNMAPIVARBPROC gl3wGetnMapivARB;
^
GL/gl3w.h:549:8: error: ‘PFNGLGETNPIXELMAPFVARBPROC’ does not name a type
extern PFNGLGETNPIXELMAPFVARBPROC gl3wGetnPixelMapfvARB;
^
GL/gl3w.h:550:8: error: ‘PFNGLGETNPIXELMAPUIVARBPROC’ does not name a type
extern PFNGLGETNPIXELMAPUIVARBPROC gl3wGetnPixelMapuivARB;
^
GL/gl3w.h:551:8: error: ‘PFNGLGETNPIXELMAPUSVARBPROC’ does not name a type
extern PFNGLGETNPIXELMAPUSVARBPROC gl3wGetnPixelMapusvARB;
^
GL/gl3w.h:552:8: error: ‘PFNGLGETNPOLYGONSTIPPLEARBPROC’ does not name a type
extern PFNGLGETNPOLYGONSTIPPLEARBPROC gl3wGetnPolygonStippleARB;
^
GL/gl3w.h:553:8: error: ‘PFNGLGETNCOLORTABLEARBPROC’ does not name a type
extern PFNGLGETNCOLORTABLEARBPROC gl3wGetnColorTableARB;
^
GL/gl3w.h:554:8: error: ‘PFNGLGETNCONVOLUTIONFILTERARBPROC’ does not name a type
extern PFNGLGETNCONVOLUTIONFILTERARBPROC gl3wGetnConvolutionFilterARB;
^
GL/gl3w.h:555:8: error: ‘PFNGLGETNSEPARABLEFILTERARBPROC’ does not name a type
extern PFNGLGETNSEPARABLEFILTERARBPROC gl3wGetnSeparableFilterARB;
^
GL/gl3w.h:556:8: error: ‘PFNGLGETNHISTOGRAMARBPROC’ does not name a type
extern PFNGLGETNHISTOGRAMARBPROC gl3wGetnHistogramARB;
^
GL/gl3w.h:557:8: error: ‘PFNGLGETNMINMAXARBPROC’ does not name a type
extern PFNGLGETNMINMAXARBPROC gl3wGetnMinmaxARB;
^
I checked in sb6.h that gl3w.h is included before any of the OpenGL dependencies and that's true so I'll really not sure what to try next. Seems to be a linking problem but it's been a long time since I've been developing in C++ and I'm not sure what to try next.
Update
I followed didierc's suggestion and found that there was a sb6code_2013_11_10/include/GL folder with gl3w.h and glcorearb.h. I temporarily moved the GL folder out of sb6code_2013_11_10/include and then ran cmake and make again and then received the following error:
Scanning dependencies of target sb6
[ 1%] Building CXX object CMakeFiles/sb6.dir/src/sb6/sb6.cpp.o
In file included from /home/lewa/workspace-cpp/opengl-superbible/sb6code_2013_11_10/include/sb6ext.h:29:0,
from /home/lewa/workspace-cpp/opengl-superbible/sb6code_2013_11_10/include/sb6.h:71,
from /home/lewa/workspace-cpp/opengl-superbible/sb6code_2013_11_10/src/sb6/sb6.cpp:26:
/usr/include/GL/glext.h:6184:181: error: conflicting declaration ‘typedef void (* PFNGLCLEARNAMEDBUFFERSUBDATAEXTPROC)(GLuint, GLenum, GLsizeiptr, GLsizeiptr, GLenum, GLenum, const void*)’
typedef void (APIENTRYP PFNGLCLEARNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLenum internalformat, GLsizeiptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data);
^
In file included from /usr/include/GL/gl3w.h:4:0,
from /home/lewa/workspace-cpp/opengl-superbible/sb6code_2013_11_10/include/sb6.h:65,
from /home/lewa/workspace-cpp/opengl-superbible/sb6code_2013_11_10/src/sb6/sb6.cpp:26:
/usr/include/GL/glcorearb.h:4348:25: error: ‘PFNGLCLEARNAMEDBUFFERSUBDATAEXTPROC’ has a previous declaration as ‘typedef void (* PFNGLCLEARNAMEDBUFFERSUBDATAEXTPROC)(GLuint, GLenum, GLenum, GLenum, GLsizeiptr, GLsizeiptr, const void*)’
typedef void (APIENTRYP PFNGLCLEARNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLenum internalformat, GLenum format, GLenum type, GLsizeiptr offset, GLsizeiptr size, const void *data);
^
make[2]: *** [CMakeFiles/sb6.dir/src/sb6/sb6.cpp.o] Error 1
make[1]: *** [CMakeFiles/sb6.dir/all] Error 2
make: *** [all] Error 2
Then I thought "Ok, then maybe I'll try using the gl3w.h and glcorearb.h that came with the sb6 package." So I restored the GL folder and then deleted the gl3w.h and glcorearb.h I previously generated with the python script and placed in /usr/include/GL. After a cmake and make I then get this error:
[ 1%] Building CXX object CMakeFiles/sb6.dir/src/sb6/sb6.cpp.o
[ 2%] Building CXX object CMakeFiles/sb6.dir/src/sb6/sb6ktx.cpp.o
[ 3%] Building CXX object CMakeFiles/sb6.dir/src/sb6/sb6object.cpp.o
[ 5%] Building CXX object CMakeFiles/sb6.dir/src/sb6/sb6shader.cpp.o
[ 6%] Building C object CMakeFiles/sb6.dir/src/sb6/gl3w.c.o
Linking CXX static library lib/libsb6.a
[ 6%] Built target sb6
Linking CXX executable bin/alienrain
CMakeFiles/alienrain.dir/src/alienrain/alienrain.cpp.o: In function `sb6::application::run(sb6::application*)':
alienrain.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0x21): undefined reference to `glfwInit'
alienrain.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0x7a): undefined reference to `glfwOpenWindowHint'
alienrain.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0x90): undefined reference to `glfwOpenWindowHint'
alienrain.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0x9f): undefined reference to `glfwOpenWindowHint'
alienrain.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0xae): undefined reference to `glfwOpenWindowHint'
alienrain.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0xc4): undefined reference to `glfwOpenWindowHint'
CMakeFiles/alienrain.dir/src/alienrain/alienrain.cpp.o:alienrain.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0xee): more undefined references to `glfwOpenWindowHint' follow
CMakeFiles/alienrain.dir/src/alienrain/alienrain.cpp.o: In function `sb6::application::run(sb6::application*)':
alienrain.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0x12c): undefined reference to `glfwGetDesktopMode'
alienrain.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0x18e): undefined reference to `glfwOpenWindow'
alienrain.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0x1a8): undefined reference to `glfwSwapInterval'
alienrain.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0x1f2): undefined reference to `glfwOpenWindow'
alienrain.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0x22e): undefined reference to `glfwSetWindowTitle'
alienrain.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0x238): undefined reference to `glfwSetWindowSizeCallback'
alienrain.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0x242): undefined reference to `glfwSetKeyCallback'
alienrain.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0x24c): undefined reference to `glfwSetMouseButtonCallback'
alienrain.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0x256): undefined reference to `glfwSetMousePosCallback'
alienrain.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0x260): undefined reference to `glfwSetMouseWheelCallback'
alienrain.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0x277): undefined reference to `glfwEnable'
alienrain.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0x27e): undefined reference to `glfwDisable'
alienrain.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0x28f): undefined reference to `glfwGetWindowParam'
alienrain.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0x373): undefined reference to `glfwGetTime'
alienrain.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0x393): undefined reference to `glfwSwapBuffers'
alienrain.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0x39d): undefined reference to `glfwGetKey'
alienrain.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0x3bd): undefined reference to `glfwGetWindowParam'
alienrain.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0x3f5): undefined reference to `glfwTerminate'
lib/libsb6.a(gl3w.c.o): In function `open_libgl':
gl3w.c:(.text+0xf): undefined reference to `dlopen'
lib/libsb6.a(gl3w.c.o): In function `close_libgl':
gl3w.c:(.text+0x2b): undefined reference to `dlclose'
lib/libsb6.a(gl3w.c.o): In function `get_proc':
gl3w.c:(.text+0x45): undefined reference to `glXGetProcAddress'
gl3w.c:(.text+0x66): undefined reference to `dlsym'
collect2: error: ld returned 1 exit status
make[2]: *** [bin/alienrain] Error 1
make[1]: *** [CMakeFiles/alienrain.dir/all] Error 2
make: *** [all] Error 2
So I'm not sure if that's progress but at least is exposes some of the snakes. Any advice on what to do next would be appreciated!
Update 2
Here's what I get from running make VERBOSE=1 with the GL folder intact (ie just as it was when I downloaded the sb6 files, but I also have glw3.h and glcorearb.h in /usr/include/GL):
/usr/bin/cmake -H/home/lewa/workspace-cpp/opengl-superbible/sb6code_2013_11_10 -B/home/lewa/workspace-cpp/opengl-superbible/sb6code_2013_11_10 --check-build-system CMakeFiles/Makefile.cmake 0
/usr/bin/cmake -E cmake_progress_start /home/lewa/workspace-cpp/opengl-superbible/sb6code_2013_11_10/CMakeFiles /home/lewa/workspace-cpp/opengl-superbible/sb6code_2013_11_10/CMakeFiles/progress.marks
make -f CMakeFiles/Makefile2 all
make[1]: Entering directory `/home/lewa/workspace-cpp/opengl-superbible/sb6code_2013_11_10'
make -f CMakeFiles/sb6.dir/build.make CMakeFiles/sb6.dir/depend
make[2]: Entering directory `/home/lewa/workspace-cpp/opengl-superbible/sb6code_2013_11_10'
cd /home/lewa/workspace-cpp/opengl-superbible/sb6code_2013_11_10 && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/lewa/workspace-cpp/opengl-superbible/sb6code_2013_11_10 /home/lewa/workspace-cpp/opengl-superbible/sb6code_2013_11_10 /home/lewa/workspace-cpp/opengl-superbible/sb6code_2013_11_10 /home/lewa/workspace-cpp/opengl-superbible/sb6code_2013_11_10 /home/lewa/workspace-cpp/opengl-superbible/sb6code_2013_11_10/CMakeFiles/sb6.dir/DependInfo.cmake --color=
make[2]: Leaving directory `/home/lewa/workspace-cpp/opengl-superbible/sb6code_2013_11_10'
make -f CMakeFiles/sb6.dir/build.make CMakeFiles/sb6.dir/build
make[2]: Entering directory `/home/lewa/workspace-cpp/opengl-superbible/sb6code_2013_11_10'
/usr/bin/cmake -E cmake_progress_report /home/lewa/workspace-cpp/opengl-superbible/sb6code_2013_11_10/CMakeFiles 51
[ 1%] Building CXX object CMakeFiles/sb6.dir/src/sb6/sb6.cpp.o
/usr/bin/c++ -D_LINUX -I/home/lewa/workspace-cpp/opengl-superbible/sb6code_2013_11_10/include -I/home/lewa/workspace-cpp/opengl-superbible/sb6code_2013_11_10/extern/glfw-2.7.6/include -o CMakeFiles/sb6.dir/src/sb6/sb6.cpp.o -c /home/lewa/workspace-cpp/opengl-superbible/sb6code_2013_11_10/src/sb6/sb6.cpp
Linking CXX static library lib/libsb6.a
/usr/bin/cmake -P CMakeFiles/sb6.dir/cmake_clean_target.cmake
/usr/bin/cmake -E cmake_link_script CMakeFiles/sb6.dir/link.txt --verbose=1
/usr/bin/ar cr lib/libsb6.a CMakeFiles/sb6.dir/src/sb6/sb6.cpp.o CMakeFiles/sb6.dir/src/sb6/sb6ktx.cpp.o CMakeFiles/sb6.dir/src/sb6/sb6object.cpp.o CMakeFiles/sb6.dir/src/sb6/sb6shader.cpp.o CMakeFiles/sb6.dir/src/sb6/gl3w.c.o
/usr/bin/ranlib lib/libsb6.a
make[2]: Leaving directory `/home/lewa/workspace-cpp/opengl-superbible/sb6code_2013_11_10'
/usr/bin/cmake -E cmake_progress_report /home/lewa/workspace-cpp/opengl-superbible/sb6code_2013_11_10/CMakeFiles 51 52 53 54 55
[ 6%] Built target sb6
make -f CMakeFiles/alienrain.dir/build.make CMakeFiles/alienrain.dir/depend
make[2]: Entering directory `/home/lewa/workspace-cpp/opengl-superbible/sb6code_2013_11_10'
cd /home/lewa/workspace-cpp/opengl-superbible/sb6code_2013_11_10 && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/lewa/workspace-cpp/opengl-superbible/sb6code_2013_11_10 /home/lewa/workspace-cpp/opengl-superbible/sb6code_2013_11_10 /home/lewa/workspace-cpp/opengl-superbible/sb6code_2013_11_10 /home/lewa/workspace-cpp/opengl-superbible/sb6code_2013_11_10 /home/lewa/workspace-cpp/opengl-superbible/sb6code_2013_11_10/CMakeFiles/alienrain.dir/DependInfo.cmake --color=
make[2]: Leaving directory `/home/lewa/workspace-cpp/opengl-superbible/sb6code_2013_11_10'
make -f CMakeFiles/alienrain.dir/build.make CMakeFiles/alienrain.dir/build
make[2]: Entering directory `/home/lewa/workspace-cpp/opengl-superbible/sb6code_2013_11_10'
/usr/bin/cmake -E cmake_progress_report /home/lewa/workspace-cpp/opengl-superbible/sb6code_2013_11_10/CMakeFiles 1
[ 7%] Building CXX object CMakeFiles/alienrain.dir/src/alienrain/alienrain.cpp.o
/usr/bin/c++ -D_LINUX -I/home/lewa/workspace-cpp/opengl-superbible/sb6code_2013_11_10/include -I/home/lewa/workspace-cpp/opengl-superbible/sb6code_2013_11_10/extern/glfw-2.7.6/include -o CMakeFiles/alienrain.dir/src/alienrain/alienrain.cpp.o -c /home/lewa/workspace-cpp/opengl-superbible/sb6code_2013_11_10/src/alienrain/alienrain.cpp
Linking CXX executable bin/alienrain
/usr/bin/cmake -E cmake_link_script CMakeFiles/alienrain.dir/link.txt --verbose=1
/usr/bin/c++ -D_LINUX CMakeFiles/alienrain.dir/src/alienrain/alienrain.cpp.o -o bin/alienrain -L/home/lewa/workspace-cpp/opengl-superbible/sb6code_2013_11_10/lib -rdynamic lib/libsb6.a -Wl,-rpath,/home/lewa/workspace-cpp/opengl-superbible/sb6code_2013_11_10/lib
CMakeFiles/alienrain.dir/src/alienrain/alienrain.cpp.o: In function `sb6::application::run(sb6::application*)':
alienrain.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0x21): undefined reference to `glfwInit'
alienrain.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0x7a): undefined reference to `glfwOpenWindowHint'
alienrain.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0x90): undefined reference to `glfwOpenWindowHint'
alienrain.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0x9f): undefined reference to `glfwOpenWindowHint'
alienrain.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0xae): undefined reference to `glfwOpenWindowHint'
alienrain.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0xc4): undefined reference to `glfwOpenWindowHint'
CMakeFiles/alienrain.dir/src/alienrain/alienrain.cpp.o:alienrain.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0xee): more undefined references to `glfwOpenWindowHint' follow
CMakeFiles/alienrain.dir/src/alienrain/alienrain.cpp.o: In function `sb6::application::run(sb6::application*)':
alienrain.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0x12c): undefined reference to `glfwGetDesktopMode'
alienrain.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0x18e): undefined reference to `glfwOpenWindow'
alienrain.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0x1a8): undefined reference to `glfwSwapInterval'
alienrain.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0x1f2): undefined reference to `glfwOpenWindow'
alienrain.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0x22e): undefined reference to `glfwSetWindowTitle'
alienrain.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0x238): undefined reference to `glfwSetWindowSizeCallback'
alienrain.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0x242): undefined reference to `glfwSetKeyCallback'
alienrain.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0x24c): undefined reference to `glfwSetMouseButtonCallback'
alienrain.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0x256): undefined reference to `glfwSetMousePosCallback'
alienrain.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0x260): undefined reference to `glfwSetMouseWheelCallback'
alienrain.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0x277): undefined reference to `glfwEnable'
alienrain.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0x27e): undefined reference to `glfwDisable'
alienrain.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0x28f): undefined reference to `glfwGetWindowParam'
alienrain.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0x373): undefined reference to `glfwGetTime'
alienrain.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0x393): undefined reference to `glfwSwapBuffers'
alienrain.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0x39d): undefined reference to `glfwGetKey'
alienrain.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0x3bd): undefined reference to `glfwGetWindowParam'
alienrain.cpp:(.text._ZN3sb611application3runEPS0_[_ZN3sb611application3runEPS0_]+0x3f5): undefined reference to `glfwTerminate'
lib/libsb6.a(gl3w.c.o): In function `open_libgl':
gl3w.c:(.text+0xf): undefined reference to `dlopen'
lib/libsb6.a(gl3w.c.o): In function `close_libgl':
gl3w.c:(.text+0x2b): undefined reference to `dlclose'
lib/libsb6.a(gl3w.c.o): In function `get_proc':
gl3w.c:(.text+0x45): undefined reference to `glXGetProcAddress'
gl3w.c:(.text+0x66): undefined reference to `dlsym'
collect2: error: ld returned 1 exit status
make[2]: *** [bin/alienrain] Error 1
make[2]: Leaving directory `/home/lewa/workspace-cpp/opengl-superbible/sb6code_2013_11_10'
make[1]: *** [CMakeFiles/alienrain.dir/all] Error 2
make[1]: Leaving directory `/home/lewa/workspace-cpp/opengl-superbible/sb6code_2013_11_10'
make: *** [all] Error 2
Update 3
I was able to find a solution to the build problem with the sb6 sample code. It turns out there is a error in the CMakeLists.txt included with the sample code where on line 13 the 'elif (UNIX)' should be 'elseif (UNIX)'. See references:
trouble trying to build opengl superbible example code
https://github.com/openglsuperbible/sb6code/issues/12
https://github.com/openglsuperbible/sb6code/issues/8
With that fix the sb6 sample code now compiles for me. However, when I try to use sb6.h in my own sample code (listed in my_application above) I still get
In file included from sb6ext.h:29:0,
from sb6.h:71,
from listing2.1.cpp:1:
/usr/include/GL/glext.h:6184:181: error: conflicting declaration ‘typedef void (* PFNGLCLEARNAMEDBUFFERSUBDATAEXTPROC)(GLuint, GLenum, GLsizeiptr, GLsizeiptr, GLenum, GLenum, const void*)’
typedef void (APIENTRYP PFNGLCLEARNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLenum internalformat, GLsizeiptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data);
^
In file included from /usr/include/GL/gl3w.h:4:0,
from sb6.h:65,
from listing2.1.cpp:1:
/usr/include/GL/glcorearb.h:4348:25: error: ‘PFNGLCLEARNAMEDBUFFERSUBDATAEXTPROC’ has a previous declaration as ‘typedef void (* PFNGLCLEARNAMEDBUFFERSUBDATAEXTPROC)(GLuint, GLenum, GLenum, GLenum, GLsizeiptr, GLsizeiptr, const void*)’
typedef void (APIENTRYP PFNGLCLEARNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLenum internalformat, GLenum format, GLenum type, GLsizeiptr offset, GLsizeiptr size, const void *data);
^
I was able to solve the sb6 sample code compilation problems by fixing a bug in CMakeLists.txt where on line 13 the 'elif (UNIX)' should be 'elseif (UNIX)'. See the following for references:
trouble trying to build opengl superbible example code
https://github.com/openglsuperbible/sb6code/issues/12
https://github.com/openglsuperbible/sb6code/issues/8
I have not solve my compilation problems when I use sb6.h in my own code yet but will update this answer when I do
When I'm compiling the Triangle project from the opengl superbible 5th ed I've this code errors
> /home/fpointbin/projects/Triangle/build> make
[ 7%] Building CXX object CMakeFiles/gltools.dir/src/GLBatch.cpp.o
[ 15%] Building CXX object CMakeFiles/gltools.dir/src/GLShaderManager.cpp.o
[ 23%] Building CXX object CMakeFiles/gltools.dir/src/GLTools.cpp.o
[ 30%] Building CXX object CMakeFiles/gltools.dir/src/GLTriangleBatch.cpp.o
[ 38%] Building CXX object CMakeFiles/gltools.dir/src/math3d.cpp.o
[ 46%] Building C object CMakeFiles/gltools.dir/src/glew.c.o
Linking CXX shared library libgltools.so
[ 46%] Built target gltools
Scanning dependencies of target gltools-static
[ 53%] Building CXX object CMakeFiles/gltools-static.dir/src/GLBatch.cpp.o
[ 61%] Building CXX object CMakeFiles/gltools-static.dir/src/GLShaderManager.cpp.o
[ 69%] Building CXX object CMakeFiles/gltools-static.dir/src/GLTools.cpp.o
[ 76%] Building CXX object CMakeFiles/gltools-static.dir/src/GLTriangleBatch.cpp.o
[ 84%] Building CXX object CMakeFiles/gltools-static.dir/src/math3d.cpp.o
[ 92%] Building C object CMakeFiles/gltools-static.dir/src/glew.c.o
Linking CXX static library libgltools.a
[ 92%] Built target gltools-static
Linking CXX executable triangle
CMakeFiles/triangle.dir/main.cpp.o: In function `ChangeSize(int, int)':
/home/fpointbin/projects/Triangle/main.cpp:22: undefined reference to `glViewport'
CMakeFiles/triangle.dir/main.cpp.o: In function `SetupRC()':
/home/fpointbin/projects/Triangle/main.cpp:32: undefined reference to `glClearColor'
/home/fpointbin/projects/Triangle/main.cpp:34: undefined reference to `GLShaderManager::InitializeStockShaders()'
/home/fpointbin/projects/Triangle/main.cpp:41: undefined reference to `GLBatch::Begin(unsigned int, unsigned int, unsigned int)'
/home/fpointbin/projects/Triangle/main.cpp:43: undefined reference to `GLBatch::End()'
CMakeFiles/triangle.dir/main.cpp.o: In function `RenderScene()':
/home/fpointbin/projects/Triangle/main.cpp:53: undefined reference to `glClear'
/home/fpointbin/projects/Triangle/main.cpp:56: undefined reference to `GLShaderManager::UseStockShader(GLT_STOCK_SHADER, ...)'
/home/fpointbin/projects/Triangle/main.cpp:57: undefined reference to `GLBatch::Draw()'
/home/fpointbin/projects/Triangle/main.cpp:60: undefined reference to `glutSwapBuffers'
CMakeFiles/triangle.dir/main.cpp.o: In function `main':
/home/fpointbin/projects/Triangle/main.cpp:68: undefined reference to `gltSetWorkingDirectory(char const*)'
/home/fpointbin/projects/Triangle/main.cpp:70: undefined reference to `glutInit'
/home/fpointbin/projects/Triangle/main.cpp:71: undefined reference to `glutInitDisplayMode'
/home/fpointbin/projects/Triangle/main.cpp:72: undefined reference to `glutInitWindowSize'
/home/fpointbin/projects/Triangle/main.cpp:73: undefined reference to `glutCreateWindow'
/home/fpointbin/projects/Triangle/main.cpp:74: undefined reference to `glutReshapeFunc'
/home/fpointbin/projects/Triangle/main.cpp:75: undefined reference to `glutDisplayFunc'
/home/fpointbin/projects/Triangle/main.cpp:77: undefined reference to `glewInit'
/home/fpointbin/projects/Triangle/main.cpp:79: undefined reference to `glewGetErrorString'
/home/fpointbin/projects/Triangle/main.cpp:85: undefined reference to `glutMainLoop'
CMakeFiles/triangle.dir/main.cpp.o: In function `__static_initialization_and_destruction_0':
/home/fpointbin/projects/Triangle/main.cpp:14: undefined reference to `GLBatch::GLBatch()'
/home/fpointbin/projects/Triangle/main.cpp:14: undefined reference to `GLBatch::~GLBatch()'
/home/fpointbin/projects/Triangle/main.cpp:15: undefined reference to `GLShaderManager::GLShaderManager()'
/home/fpointbin/projects/Triangle/main.cpp:15: undefined reference to `GLShaderManager::~GLShaderManager()'
CMakeFiles/triangle.dir/main.cpp.o: In function `GLBatch::CopyVertexData3f(float*)':
/home/fpointbin/projects/Triangle/include/GLBatch.h:89: undefined reference to `GLBatch::CopyVertexData3f(float (*) [3])'
collect2: ld returned 1 exit status
make[2]: *** [triangle] Error 1
make[1]: *** [CMakeFiles/triangle.dir/all] Error 2
make: *** [all] Error 2
*** Failed ***
This is my Cmakelist.txt:
cmake_minimum_required (VERSION 2.6)
project(triangle)
find_package(X11)
find_package(OpenGL REQUIRED)
find_package(GLUT REQUIRED)
find_library(M_LIBRARY m)
find_library(GLEW_LIBRARY GLEW)
set ( INCLUDE_DIRS
"${CMAKE_SOURCE_DIR}/include"
${INCLUDE_DIRS}
)
include_directories (
${INCLUDE_DIRS}
)
if(UNIX)
set ( INCLUDE_DIRS
"/usr/include"
"/usr/local/include"
"/usr/include/GL"
${INCLUDE_DIRS}
)
endif(UNIX)
set ( GLTOOLS_HDRS
"${CMAKE_SOURCE_DIR}/include/GLBatchBase.h"
"${CMAKE_SOURCE_DIR}/include/GLBatch.h"
"${CMAKE_SOURCE_DIR}/include/GLFrame.h"
"${CMAKE_SOURCE_DIR}/include/GLFrustum.h"
"${CMAKE_SOURCE_DIR}/include/GLGeometryTransform.h"
"${CMAKE_SOURCE_DIR}/include/GLMatrixStack.h"
"${CMAKE_SOURCE_DIR}/include/GLShaderManager.h"
"${CMAKE_SOURCE_DIR}/include/GLTools.h"
"${CMAKE_SOURCE_DIR}/include/GLTriangleBatch.h"
"${CMAKE_SOURCE_DIR}/include/math3d.h"
"${CMAKE_SOURCE_DIR}/include/StopWatch.h"
"${CMAKE_SOURCE_DIR}/include/glew.h"
)
set ( GLTOOLS_SRCS
"${CMAKE_SOURCE_DIR}/src/GLBatch.cpp"
"${CMAKE_SOURCE_DIR}/src/GLShaderManager.cpp"
"${CMAKE_SOURCE_DIR}/src/GLTools.cpp"
"${CMAKE_SOURCE_DIR}/src/GLTriangleBatch.cpp"
"${CMAKE_SOURCE_DIR}/src/math3d.cpp"
"${CMAKE_SOURCE_DIR}/src/glew.c"
)
add_library ( gltools-static ${GLTOOLS_SRCS})
add_library ( gltools SHARED ${GLTOOLS_SRCS})
target_link_libraries (gltools ${OPENGL_LIBRARIES} ${GLUT_LIBRARIES} ${GLEW_LIBRARY} ${M_LIBRARY} ${X11_LIBRARIES})
target_link_libraries (gltools-static ${OPENGL_LIBRARIES} ${GLUT_LIBRARIES} ${GLEW_LIBRARY} ${M_LIBRARY} ${X11_LIBRARIES})
set_target_properties(gltools-static PROPERTIES OUTPUT_NAME gltools)
add_executable(triangle main.cpp)
What's the problem?
You are right, the errors are not from the compiler, they are from the linker. Since a lot of the undefined references are about glut functions, first verify that you can link glut properly. Have a look at this link - how to set up Glut.
Most likely you didn't include a header or the include directive in the makefile is wrong because the errors are pretty clear to me: the compiler can't find the core function of OpenGL which are included in the OpenGL headers.