I am in a rather small hobby project, we are creating a game, or at least trying to do so... The main issue we are facing is the fact that we are able to compile the project on MacOS and Linux, but not on Windows.
We are using GLFW as an interface to OpenGL, so it is required for us to get anything visible on the screen. Problem is that when we tell Make to do its thing, it compiles each individual module but fails to link them because of undefined references. While that may make sense the weird thing is that these unknown references all have the prefix __imp_, which isn't present in source. Example: We used the method glfwInit but when trying to make the project we get: graphicsengine/libgraphicsengine.a(graphics.cpp.obj):graphics.cpp:(.text+0xa): undefined reference to `_imp__glfwInit'
Having done some research I found This SO Question of which i tried the answer. It failed, due to the fact that the only lib in there after compilation is libglfw3.a, no sort of dll or hints at a dll. Renaming this file accordingly did not help, neither did placing the precompiled binary. Deleting this file results in it recompiling and reappearing, so clearly make knows where it is.
We also tried switching to clang because maybe it has a more intelligent linker, but it didn't want to compile anything in the first place.
I performed a lot of research on this and I found countless SO answers and forum threads of people with similar or even identical problems, every single one had a different solution and none of them worked for us.
To generate the Makefile we are using CMake with the following script in the main subdirectory (don't worry, it gets called from above, we got that working so far):
set(GLFW_BUILD_DOCS OFF CACHE BOOL "" FORCE)
set(GLFW_BUILD_TESTS OFF CACHE BOOL "" FORCE)
set(GLFW_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
set(GLFW_INSTALL OFF CACHE BOOL "" FORCE)
add_subdirectory(graphicsengine)
add_subdirectory(fileSys)
add_subdirectory(networking)
add_subdirectory(game)
add_subdirectory(glfw-3.2.1)
include_directories(glfw-3.2.1/include)
if (UNIX AND NOT APPLE)
find_package(OpenGL REQUIRED)
include_directories(${OPENGL_INCLUDE_DIR})
endif()
add_executable(${PROJECT_NAME} "${CMAKE_CURRENT_SOURCE_DIR}/main.cpp")
target_link_libraries(${PROJECT_NAME} graphicsengine fileSys networking game)
if (APPLE)
target_link_libraries(${PROJECT_NAME} "-framework OpenGL")
endif()
if (WIN32)
target_link_libraries(${PROJECT_NAME} opengl32 gdi32)
endif()
if (UNIX AND NOT APPLE)
target_link_libraries(${PROJECT_NAME} ${OPENGL_gl_LIBRARY})
endif()
target_link_libraries(${PROJECT_NAME} glfw)
install(TARGETS ${PROJECT_NAME} DESTINATION ${INSTALL_DIR})
The rest of the important cmake calls are in the parent directory
Here is a full log of cmake/make that a custom build script calls:
debug
release
-- The CXX compiler identification is GNU 5.3.0
-- Check for working CXX compiler: D:/MinGW/bin/g++.exe
-- Check for working CXX compiler: D:/MinGW/bin/g++.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- The C compiler identification is GNU 5.3.0
-- Check for working C compiler: D:/MinGW/bin/gcc.exe
-- Check for working C compiler: D:/MinGW/bin/gcc.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE
-- Could NOT find Vulkan (missing: VULKAN_INCLUDE_DIR)
-- Looking for dinput.h
-- Looking for dinput.h - not found
-- Looking for xinput.h
-- Looking for xinput.h - not found
-- Performing Test _GLFW_HAS_DEP
-- Performing Test _GLFW_HAS_DEP - Success
-- Performing Test _GLFW_HAS_ASLR
-- Performing Test _GLFW_HAS_ASLR - Success
-- Performing Test _GLFW_HAS_64ASLR
-- Performing Test _GLFW_HAS_64ASLR - Failed
-- Using Win32 for window creation
-- Configuring done
-- Generating done
-- Build files have been written to: D:/cpp-neon/Workspace/Supermerged
--------------MAKE STARTS HERE--------------
[ 60%] Built target glfw
[ 68%] Built target graphicsengine
[ 76%] Built target fileSys
[ 84%] Built target networking
[ 92%] Built target game
[ 96%] Linking CXX executable Submerged_PR0.exe
graphicsengine/libgraphicsengine.a(graphics.cpp.obj):graphics.cpp:(.text+0xa): undefined reference to `_imp__glfwInit'
graphicsengine/libgraphicsengine.a(graphics.cpp.obj):graphics.cpp:(.text+0x45): undefined reference to `_imp__glfwCreateWindow'
graphicsengine/libgraphicsengine.a(graphics.cpp.obj):graphics.cpp:(.text+0x55): undefined reference to `_imp__glfwTerminate'
graphicsengine/libgraphicsengine.a(graphics.cpp.obj):graphics.cpp:(.text+0x64): undefined reference to `_imp__glfwMakeContextCurrent'
graphicsengine/libgraphicsengine.a(graphics.cpp.obj):graphics.cpp:(.text+0x71): undefined reference to `_imp__glfwWindowShouldClose'
graphicsengine/libgraphicsengine.a(graphics.cpp.obj):graphics.cpp:(.text+0x98): undefined reference to `_imp__glfwSwapBuffers'
graphicsengine/libgraphicsengine.a(graphics.cpp.obj):graphics.cpp:(.text+0x9f): undefined reference to `_imp__glfwPollEvents'
graphicsengine/libgraphicsengine.a(graphics.cpp.obj):graphics.cpp:(.text+0xa8): undefined reference to `_imp__glfwTerminate'
collect2.exe: error: ld returned 1 exit status
source\CMakeFiles\Submerged_PR0.dir\build.make:101: recipe for target 'source/Submerged_PR0.exe' failed
mingw32-make[2]: *** [source/Submerged_PR0.exe] Error 1
CMakeFiles\Makefile2:102: recipe for target 'source/CMakeFiles/Submerged_PR0.dir/all' failed
mingw32-make[1]: *** [source/CMakeFiles/Submerged_PR0.dir/all] Error 2
Makefile:128: recipe for target 'all' failed
mingw32-make: *** [all] Error 2
Make Failed, Aborting Install
PS D:\cpp-neon\Workspace\Supermerged>
In case you want to know, this is our project structure:
The CMakeLists.txt above is the one you see in /source
The rest of the modules are built in the same way, except for glfw, which is the one you can find on their website
At this point in time we are more or less helpless and tired of looking for a solution, at the point where we just try stuff until it kind of works but ends up a giant mess of everything that should never have existed, we all know how that ends up... (cough) which of these branches was the one where i did the thing that made it do the other thing?(cough) We hope that some of you (SO) might have a better approach to finding the solution than any of us. Feel free to ask anything else that might help you find something that works!
Thanks in advance!
In the name of: sDev
We found it!
The problem was actually in our graphics.hpp:
We had the line #define GLFW_DLL
Which was wrong because it had to be
#define GLFW_STATIC
And now it works
Related
I'm trying to build a project using Tensorflow Lite on my debian 11 machine, however it says I'm getting an undefined reference on some functions.
Here is the code I'm trying to run:
// Works
std::unique_ptr<tflite::FlatBufferModel> model =
tflite::FlatBufferModel::BuildFromFile(filename);
TFLITE_MINIMAL_CHECK(model != nullptr);
// Undefined referance:
tflite::ops::builtin::BuiltinOpResolver resolver;
std::unique_ptr<tflite::Interpreter> interpreter;
tflite::InterpreterBuilder(*model, resolver)(&interpreter);
The first few lines in on itself works fine. When I add the lines below starting from BuiltinOpResolver I'm getting the following error when running make:
[ 50%] Linking CXX executable TFLiteCheck
/usr/bin/ld: CMakeFiles/TFLiteCheck.dir/main.cpp.o: in function `main':
main.cpp:(.text+0x106): undefined reference to `tflite::InterpreterBuilder::InterpreterBuilder(tflite::FlatBufferModel const&, tflite::OpResolver const&)'
/usr/bin/ld: main.cpp:(.text+0x11f): undefined reference to `tflite::InterpreterBuilder::operator()(std::unique_ptr<tflite::Interpreter, std::default_delete<tflite::Interpreter> >*)'
/usr/bin/ld: main.cpp:(.text+0x12e): undefined reference to `tflite::InterpreterBuilder::~InterpreterBuilder()'
/usr/bin/ld: main.cpp:(.text+0x19e): undefined reference to `tflite::InterpreterBuilder::~InterpreterBuilder()'
/usr/bin/ld: CMakeFiles/TFLiteCheck.dir/main.cpp.o: in function `std::default_delete<tflite::Interpreter>::operator()(tflite::Interpreter*) const':
main.cpp:(.text._ZNKSt14default_deleteIN6tflite11InterpreterEEclEPS1_[_ZNKSt14default_deleteIN6tflite11InterpreterEEclEPS1_]+0x1e): undefined reference to `tflite::Interpreter::~Interpreter()'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/TFLiteCheck.dir/build.make:104: TFLiteCheck] Error 1
make[1]: *** [CMakeFiles/Makefile2:95: CMakeFiles/TFLiteCheck.dir/all] Error 2
make: *** [Makefile:103: all] Error 2
I've tried [this answer][1] but it's on an arm architecture while I'm on an intel chip, and when I try it regardless I'm getting a completely different error that I've never seen before.
I've followed these steps to setup TFLite:
Got the source code from tenserflow github page
Got bazel version 3.7.2 (bazel-3.7.2-linux-x86_64)
Ran python3 ./configure.py setting everything to default and opting to say n to everything
Ran bazel build -c opt //tensorflow/lite:libtensorflowlite.so --local_ram_resources=10240 --config=noaws(Tried it with and without --local_ram_resources=10240 --config=noaws params)
Move the .so file to the designated file, right next to tenserflow include files.
Ran cmake .. and make on the build folder with the following CMake file:
cmake_minimum_required(VERSION 3.17)
project(TFLiteCheck)
set(CMAKE_CXX_STANDARD 14)
# include has 2 subdirectories: tensorflow and flatbuffers
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/third-party/tflite-dist/include/)
# lib has 1 file: libtensorflowlite.so
ADD_LIBRARY(tensorflowlite SHARED IMPORTED)
set_property(TARGET tensorflowlite PROPERTY IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/third-party/tflite-dist/libs/linux_x64/libtensorflowlite.so)
add_executable(TFLiteCheck main.cpp)
target_link_libraries(TFLiteCheck PUBLIC tensorflowlite)
And running make results in the above error. What could be the problem? Is there a better way to setup tenserflow? Like I've said only running FlatBufferModel works just fine.
Update:
By removing the -J flag from the official build instructions I've managed to built the project propperly. However when I use the official cmake example:
cmake_minimum_required(VERSION 3.16)
project(minimal C CXX)
set(TENSORFLOW_SOURCE_DIR "" CACHE PATH
"Directory that contains the TensorFlow project" )
if(NOT TENSORFLOW_SOURCE_DIR)
get_filename_component(TENSORFLOW_SOURCE_DIR
"${CMAKE_CURRENT_LIST_DIR}/../../../../" ABSOLUTE)
endif()
add_subdirectory(
"${TENSORFLOW_SOURCE_DIR}/user/tensorflow_src/tensorflow/lite"
"${CMAKE_CURRENT_BINARY_DIR}/tensorflow-lite" EXCLUDE_FROM_ALL)
add_executable(minimal main.cpp)
target_link_libraries(minimal tensorflow-lite)
When I run this with my example main.cpp using cmake . provided above, I'm getting this output and the terminal is stuck like this, without resolving:
user#debian:~/Desktop/SmartAlpha/tf_test$ cmake .
-- Setting build type to Release, for debug builds use'-DCMAKE_BUILD_TYPE=Debug'.
CMake Warning at abseil-cpp/CMakeLists.txt:70 (message):
A future Abseil release will default ABSL_PROPAGATE_CXX_STD to ON for CMake
3.8 and up. We recommend enabling this option to ensure your project still
builds correctly.
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE
It's not frozen or anything, it just stays like this untill I hit ctrl+c to break it, without ever finishing.
Update 2:
The compilation finished with this error:
user#debian:~/Desktop/SmartAlpha/tf_test$ cmake .
-- Setting build type to Release, for debug builds use'-DCMAKE_BUILD_TYPE=Debug'.
CMake Warning at abseil-cpp/CMakeLists.txt:70 (message):
A future Abseil release will default ABSL_PROPAGATE_CXX_STD to ON for CMake
3.8 and up. We recommend enabling this option to ensure your project still
builds correctly.
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE
CMake Error at eigen/CMakeLists.txt:36 (message):
In-source builds not allowed. Please make a new directory (called a build
directory) and run CMake from there. You may need to remove
CMakeCache.txt.
-- Configuring incomplete, errors occurred!
See also "/home/user/Desktop/tf_test/CMakeFiles/CMakeOutput.log".
See also "/home/user/Desktop/tf_test/CMakeFiles/CMakeError.log".
Which cmake cache is it talking about? The one in my projects directory or the one inside my tensorflow build?
Am I missing spmething?
[1]: Tensorflow Lite error undefined reference to `tflite::DefaultErrorReporter()'
Cmake 3.15 32-bit
Assimp 4.1.0
Hi there, I'm experiencing some difficulties with cmake and assimp. For the past few days I have been trying to generate an assimp workspace for CodeBlocks via cmake.
I have tried to generate a solution with CMD and CmakeGUI approach but without satisfying results.
In GUI standard procedure for generating projects was followed by defining proper source and target paths and choosing appropriate generators (CodeBlocks MinGW Makefiles).
Code used in cmd for generating assimp project:
cmake -G "CodeBlocks - MinGW Makefiles" MakeLists.txt -S "source path" -B "build path"
Info log that I get after generating files:
-- The C compiler identification is GNU 8.2.0
-- The CXX compiler identification is GNU 8.2.0
-- Check for working C compiler: C:/MinGW/bin/gcc.exe
-- Check for working C compiler: C:/MinGW/bin/gcc.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: C:/MinGW/bin/g++.exe
-- Check for working CXX compiler: C:/MinGW/bin/g++.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Shared libraries enabled
-- Looking for DirectX...
-- DirectX_PREFIX_PATH changed.
-- Found DirectX: C:/MinGW/lib/libd3d9.a
-- DX lib dir: C:/MinGW/lib
-- Looking for ZLIB...
-- Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE)
-- Could not locate ZLIB
-- compiling zlib from souces
CMake Deprecation Warning at contrib/zlib/CMakeLists.txt:8 (cmake_policy):
The OLD behavior for policy CMP0048 will be removed from a future version
of CMake.
The cmake-policies(7) manual explains that the OLD behaviors of all
policies are deprecated and that a policy should be set to OLD only under
specific short-term circumstances. Projects should be ported to the NEW
behavior and not rely on setting a policy to OLD.
-- Looking for sys/types.h
-- Looking for sys/types.h - found
-- Looking for stdint.h
-- Looking for stdint.h - found
-- Looking for stddef.h
-- Looking for stddef.h - found
-- Check size of off64_t
-- Check size of off64_t - done
-- Looking for fseeko
-- Looking for fseeko - not found
-- Looking for unistd.h
-- Looking for unistd.h - found
-- Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE)
-- Could NOT find rt (missing: RT_LIBRARY)
INFO RT-extension not found. glTF import/export will be built without Open3DGC-compression.
-- Enabled formats: AMF 3DS AC ASE ASSBIN ASSXML B3D BVH COLLADA DXF CSM HMP IRRMESH IRR LWO LWS MD2 MD3 MD5 MDC MDL NFF NDO OFF OBJ OGRE OPENGEX PLY MS3D COB BLEND IFC XGL FBX Q3D Q3BSP RAW SIB SMD STL TERRAGEN 3D X X3D GLTF 3MF MMD
-- Disabled formats:
-- Could NOT find IL (missing: IL_LIBRARIES IL_INCLUDE_DIR)
CMake Warning at CMakeLists.txt:439 (MESSAGE):
Build of assimp_qt_viewer is disabled. Unsatisfied dendencies: Qt5 DevIL
-- Configuring done
-- Generating done
-- Build files have been written to: E:/Assimp
Unfortunately the project fails to build in CodeBlocks with the following build log:
Checking if target is up-to-date: mingw32-make.exe -q -f Makefile all
Running command: C:/TDM-GCC-64/bin/mingw32-make.exe -f "E:/Assimp/Makefile" VERBOSE=1 all
"C:\Program Files\CMake\bin\cmake.exe" -SC:\Users\ognje\Downloads\assimp-4.1.0 -B"E:\Assimp" --check-build-system CMakeFiles\Makefile.cmake 0
"C:\Program Files\CMake\bin\cmake.exe" -E cmake_progress_start "E:\Assimp\CMakeFiles" "E:\Assimp\CMakeFiles\progress.marks"
C:/TDM-GCC-64/bin/mingw32-make.exe -f CMakeFiles\Makefile2 all
mingw32-make.exe[1]: Entering directory 'E:/Assimp'
C:/TDM-GCC-64/bin/mingw32-make.exe -f contrib\zlib\CMakeFiles\zlib.dir\build.make contrib/zlib/CMakeFiles/zlib.dir/depend
mingw32-make.exe[2]: Entering directory 'E:/Assimp'
[ 1%] Generating zlib1rc.obj
cd /d E:\PROGRA~3\PROGRA~1\Assimp\contrib\zlib && C:\MinGW\bin\windres.exe -D GCC_WINDRES -I C:/Users/ognje/Downloads/assimp-4.1.0/contrib/zlib -I "E:/Assimp/contrib/zlib" -o "E:/Assimp/contrib/zlib/zlib1rc.obj" -i C:/Users/ognje/Downloads/assimp-4.1.0/contrib/zlib/win32/zlib1.rc
gcc: error: i\: No such file or directory
gcc: error: Assimp/contrib/zlib: No such file or directory
C:\MinGW\bin\windres.exe: preprocessing failed.
mingw32-make.exe[2]: *** [contrib/zlib/zlib1rc.obj] Error 1
mingw32-make.exe[1]: *** [contrib/zlib/CMakeFiles/zlib.dir/all] Error 2
mingw32-make.exe: *** [all] Error 2
contrib\zlib\CMakeFiles\zlib.dir\build.make:60: recipe for target 'contrib/zlib/zlib1rc.obj' failed
mingw32-make.exe[2]: Leaving directory 'E:/Assimp'
CMakeFiles\Makefile2:134: recipe for target 'contrib/zlib/CMakeFiles/zlib.dir/all' failed
mingw32-make.exe[1]: Leaving directory 'E:/Assimp'
E:/Assimp/Makefile:128: recipe for target 'all' failed
Process terminated with status 2 (0 minute(s), 0 second(s))
6 error(s), 0 warning(s) (0 minute(s), 0 second(s))
Disclaimer:
Naturally I've already googled and tried all of the already existing solutions on the web [1] for this particular problem and disappointingly none of them work. I don't know much about compiling and libraries to be honest but in my opinion when reading the error logs I would say that the problem stems from zlib files, right? Can anyone help me with this problem? Thank you in advance.
The issue is caused by a wrong detected environment. The zlib-script tries to use the following option for the windows-resource-build:
C:\MinGW\bin\windres.exe -D GCC_WINDRES -I C:/Users/ognje/Downloads/assimp-4.1.0/contrib/zlib -I "E:/Assimp/contrib/zlib" -o "E:/Assimp/contrib/zlib/zlib1rc.obj" -i C:/Users/ognje/Downloads/assimp-4.1.0/contrib/zlib/win32/zlib1.rc
The option -i will be identified as a file-token:
gcc: error: i\: No such file or directory
And so the build for zlib failes because the option, which was used as an argument confuses the gcc-parsing of the following stuff, in this case the target zlib:
gcc: error: Assimp/contrib/zlib: No such file or directory
I guess this is caused by a missing identification which code has to be build when using your special version of mingw. Could you please open an issue report with the veYOu can do rsion of assimp you are using and which gcc-version is used in your build. You can do this here: Issue-tracker of Asset-Importer-Lib Project
Introduction
I'm trying to cross compile to Windows from Linux using MinGW-W64.
I had it working before I added enet to my project, however I'm now receiving issues with linking to enet
CMake finds enet correctly. ENET_LIBRARY and ENET_INCLUDE_DIR are set to the right locations.
ENet contains the symbols, as verified using /usr/x86_64-w64-mingw32/bin/objdump /usr/local/mingw64/lib/libenet.a -t
Build fails with "undefined reference to `enet_address_set_host'"
I'm able to compile the same code base natively using Visual Studio and VCPkg
Edit: Checking the contents of libenet.a verifies that it's a problem with cross-compiling enet, not my program in particular
None of my other dependencies use GNU autoconf, so I expect there's a problem there.
The Error
-- The C compiler identification is GNU 8.2.0
-- The CXX compiler identification is GNU 8.2.0
-- Check for working C compiler: /usr/bin/x86_64-w64-mingw32-gcc
-- Check for working C compiler: /usr/bin/x86_64-w64-mingw32-gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/x86_64-w64-mingw32-g++
-- Check for working CXX compiler: /usr/bin/x86_64-w64-mingw32-g++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found SFML 2.5 in /usr/local/mingw64/include
-- Found SFGUI in /usr/local/mingw64/include
-- Found Thor in /usr/local/mingw64/include
-- Found Lua in /usr/local/mingw64/include/lua5.1/
-- Found Lua: /usr/local/mingw64/lib/liblua5.1.a
-- Found ENet: /usr/local/mingw64/lib/libenet.a
-- Found ENet in /usr/local/mingw64/include
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - found
-- Found Threads: TRUE
/usr/local/mingw64/lib/liblua5.1.a/usr/local/mingw64/lib/libenet.awsock32ws2_32winmm
-- Adding executable: client (with server)
-- Configuring done
-- Generating done
-- Build files have been written to: /home/ruben/dev/rvwp
Scanning dependencies of target rvwp
[SNIP]
[ 98%] Building CXX object CMakeFiles/rvwp.dir/source/tests/t_chunk.cpp.obj
[100%] Linking CXX executable bin/rvwp.exe
/usr/lib/gcc/x86_64-w64-mingw32/8.2.0/../../../../x86_64-w64-mingw32/bin/ld: CMakeFiles/rvwp.dir/objects.a(address.cpp.obj):address.cpp:(.text+0xc6): undefined reference to `enet_address_set_host'
/usr/lib/gcc/x86_64-w64-mingw32/8.2.0/../../../../x86_64-w64-mingw32/bin/ld: CMakeFiles/rvwp.dir/objects.a(net.cpp.obj):net.cpp:(.text+0x105): undefined reference to `enet_initialize'
/usr/lib/gcc/x86_64-w64-mingw32/8.2.0/../../../../x86_64-w64-mingw32/bin/ld: CMakeFiles/rvwp.dir/objects.a(net.cpp.obj):net.cpp:(.text+0x204): undefined reference to `enet_packet_create'
/usr/lib/gcc/x86_64-w64-mingw32/8.2.0/../../../../x86_64-w64-mingw32/bin/ld: CMakeFiles/rvwp.dir/objects.a(net.cpp.obj):net.cpp:(.text+0x217): undefined reference to `enet_peer_send'
/usr/lib/gcc/x86_64-w64-mingw32/8.2.0/../../../../x86_64-w64-mingw32/bin/ld: CMakeFiles/rvwp.dir/objects.a(net.cpp.obj):net.cpp:(.text+0x29f): undefined reference to `enet_packet_create'
/usr/lib/gcc/x86_64-w64-mingw32/8.2.0/../../../../x86_64-w64-mingw32/bin/ld: CMakeFiles/rvwp.dir/objects.a(net.cpp.obj):net.cpp:(.text+0x2b3): undefined reference to `enet_peer_send'
/usr/lib/gcc/x86_64-w64-mingw32/8.2.0/../../../../x86_64-w64-mingw32/bin/ld: CMakeFiles/rvwp.dir/objects.a(net.cpp.obj):net.cpp:(.text+0x5af): undefined reference to `enet_host_destroy'
/usr/lib/gcc/x86_64-w64-mingw32/8.2.0/../../../../x86_64-w64-mingw32/bin/ld: CMakeFiles/rvwp.dir/objects.a(net.cpp.obj):net.cpp:(.text+0x65b): undefined reference to `enet_host_create'
/usr/lib/gcc/x86_64-w64-mingw32/8.2.0/../../../../x86_64-w64-mingw32/bin/ld: CMakeFiles/rvwp.dir/objects.a(net.cpp.obj):net.cpp:(.text+0x91f): undefined reference to `enet_host_create'
/usr/lib/gcc/x86_64-w64-mingw32/8.2.0/../../../../x86_64-w64-mingw32/bin/ld: CMakeFiles/rvwp.dir/objects.a(net.cpp.obj):net.cpp:(.text+0x950): undefined reference to `enet_host_connect'
/usr/lib/gcc/x86_64-w64-mingw32/8.2.0/../../../../x86_64-w64-mingw32/bin/ld: CMakeFiles/rvwp.dir/objects.a(net.cpp.obj):net.cpp:(.text+0x96c): undefined reference to `enet_host_service'
/usr/lib/gcc/x86_64-w64-mingw32/8.2.0/../../../../x86_64-w64-mingw32/bin/ld: CMakeFiles/rvwp.dir/objects.a(net.cpp.obj):net.cpp:(.text+0x1023): undefined reference to `enet_host_service'
/usr/lib/gcc/x86_64-w64-mingw32/8.2.0/../../../../x86_64-w64-mingw32/bin/ld: CMakeFiles/rvwp.dir/objects.a(net.cpp.obj):net.cpp:(.text+0x1437): undefined reference to `enet_packet_destroy'
/usr/lib/gcc/x86_64-w64-mingw32/8.2.0/../../../../x86_64-w64-mingw32/bin/ld: CMakeFiles/rvwp.dir/objects.a(net.cpp.obj):net.cpp:(.text+0x121): undefined reference to `enet_deinitialize'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/rvwp.dir/build.make:991: bin/rvwp.exe] Error 1
make[1]: *** [CMakeFiles/Makefile2:73: CMakeFiles/rvwp.dir/all] Error 2
make: *** [Makefile:130: all] Error 2
Cross-compiling Enet
To cross compile enet, I use the following script
#!/bin/bash
TOOLSET="x86_64-w64-mingw32"
wget http://enet.bespin.org/download/enet-1.3.13.tar.gz
tar -xzf enet-1.3.13.tar.gz
cd enet-1.3.13
./configure \
--build=${TOOLSET} \
--host=x86_64-windows \
--target=${TOOLSET} \
--prefix=/usr/local/mingw64 \
--enable-shared
make -j3
sudo make install
My Program
I'm using cmake to generate the makefiles, and a toolchain to allow cross-compilation. The program compiles with SFML, thor, std::thread, and Lua fine. None of these libraries use GNU autoconf
My CMakeLists.txt looks like this:
find_package(ENet REQUIRED)
include_directories(${ENET_INCLUDE_DIR})
set(BASE_LIBRARIES ${CMAKE_THREAD_LIBS_INIT} ${LUA_LIBRARY} ${CMAKE_DL_LIBS} ${ENET_LIBRARY})
set(BASE_LIBRARIES ${BASE_LIBRARIES} wsock32 ws2_32 winmm)
message(${BASE_LIBRARIES})
set(EXECUTABLE_NAME "rvwp")
add_executable(${EXECUTABLE_NAME} WIN32 ${CLIENT_SRC})
set_target_properties(${EXECUTABLE_NAME} PROPERTIES BUILD_WITH_INSTALL_RPATH true)
install(TARGETS ${EXECUTABLE_NAME} DESTINATION bin)
target_link_libraries(${EXECUTABLE_NAME} ${BASE_LIBRARIES} ${SFML_LIBRARIES} ${SFGUI_LIBRARY} ${THOR_LIBRARY})
The findENet file looks like this:
FIND_PATH(ENET_INCLUDE_DIR enet/enet.h
PATHS
$ENV{ENETDIR}
/usr/local
/usr
PATH_SUFFIXES include)
FIND_LIBRARY(ENET_LIBRARY
NAMES enet
PATHS
$ENV{ENETDIR}
/usr/local
/usr
PATH_SUFFIXES lib)
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(ENet DEFAULT_MSG ENET_LIBRARY ENET_INCLUDE_DIR)
IF (ENet_FOUND)
MESSAGE(STATUS "Found ENet in ${ENET_INCLUDE_DIR}")
IF(WIN32)
SET(WINDOWS_ENET_DEPENDENCIES "ws2_32;winmm")
SET(ENET_LIBRARIES ${ENET_LIBRARY} ${WINDOWS_ENET_DEPENDENCIES})
ELSE(WIN32)
SET(ENET_LIBRARIES ${ENET_LIBRARY})
ENDIF(WIN32)
ENDIF (ENet_FOUND)
MARK_AS_ADVANCED(ENET_LIBRARY ENET_LIBRARIES ENET_INCLUDE_DIR)
The tool chain looks like this:
# Sample toolchain file for building for Windows from an Ubuntu Linux system.
#
# Typical usage:
# *) install cross compiler: `sudo apt-get install mingw-w64 g++-mingw-w64`
# *) cd build
# *) cmake -DCMAKE_TOOLCHAIN_FILE=~/Toolchain-Ubuntu-mingw64.cmake ..
set(CMAKE_SYSTEM_NAME Windows)
set(TOOLCHAIN_PREFIX x86_64-w64-mingw32)
# cross compilers to use for C and C++
set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}-gcc)
set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}-g++)
set(CMAKE_RC_COMPILER ${TOOLCHAIN_PREFIX}-windres)
SET( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libgcc -static-libstdc++" )
# target environment on the build host system
# set 1st to dir with the cross compiler's C/C++ headers/libs
set(CMAKE_FIND_ROOT_PATH /usr/${TOOLCHAIN_PREFIX} /usr/local/mingw64 ./extlibs)
set(LUA_INCLUDE_DIR /usr/local/mingw64/include/lua5.1/)
set(LUA_LIBRARY /usr/local/mingw64/lib/liblua5.1.a)
set(OPENAL_LIBRARY /usr/local/mingw64/lib/libopenal32.a)
# modify default behavior of FIND_XXX() commands to
# search for headers/libs in the target environment and
# search for programs in the build host environment
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
The linklibs.rsp file is used to pass linking commands to the linker, here is its value:
/usr/local/mingw64/lib/liblua5.1.a /usr/local/mingw64/lib/libenet.a -lwsock32 -lws2_32 -lwinmm /usr/local/mingw64/lib/libsfml-system.a /usr/local/mingw64/lib/libsfml-window.a /usr/local/mingw64/lib/libsfml-graphics.a /usr/local/mingw64/lib/libsfml-network.a /usr/local/mingw64/lib/libsfml-audio.a /usr/local/mingw64/bin/sfgui.dll /usr/local/mingw64/bin/libthor.dll -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32
(EDIT) AR Formats
Extracting the not-working libenet.a and using file results in this:
callbacks.o: ELF 64-bit LSB relocatable, x86-64, version 1 (SYSV), with debug_info, not stripped
Extracting the working libsfml-graphics.a results in this:
d000508.o: Intel amd64 COFF object file, no line number info, not stripped, 5 sections, symbol offset=0x144, 8 symbols
So it appears that the problem is in compiling enet
I've been trying to get PCL (1.8) working properly on my system (Ubuntu 16.04) but I am struggling to get even the basic tutorial to work. I could not install the prebuilt binaries supplied by pointclouds.org so instead followed the answer from this post and used the native repository from Ubuntu to install v1.8.
I then began to run into the same issues raised in this question. I fixed some of them myself using symlinks to correct paths broken by renaming and also installed the missing packages that I could. However I am unable to successfully create a usable makefile.
I am trying to follow this tutorial from pointclouds.org just so I can make sure everything is working.
Output from running cmake:
-- The C compiler identification is GNU 4.9.3
-- The CXX compiler identification is GNU 4.9.3
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Checking for module 'eigen3'
-- Found eigen3, version 3.2.92
-- Found eigen: /usr/include/eigen3
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE
-- Boost version: 1.58.0
-- Found the following Boost libraries:
-- system
-- filesystem
-- thread
-- date_time
-- iostreams
-- serialization
-- chrono
-- atomic
-- regex
-- Checking for module 'libopenni'
-- Found libopenni, version 1.5.4.0
-- Found openni: /usr/lib/libOpenNI.so
-- Checking for module 'libopenni2'
-- Found libopenni2, version 2.2.0.3
-- Found OpenNI2: /usr/lib/libOpenNI2.so
** WARNING ** io features related to pcap will be disabled
** WARNING ** io features related to png will be disabled
-- The imported target "vtkRenderingPythonTkWidgets" references the file
"/usr/lib/x86_64-linux-gnu/libvtkRenderingPythonTkWidgets.so"
but this file does not exist. Possible reasons include:
* The file was deleted, renamed, or moved to another location.
* An install or uninstall procedure did not complete successfully.
* The installation package was faulty and contained
"/usr/lib/cmake/vtk-6.2/VTKTargets.cmake"
but not all the files it references.
-- Found libusb-1.0: /usr/include
-- looking for PCL_COMMON
-- Found PCL_COMMON: /usr/lib/x86_64-linux-gnu/libpcl_common.so
-- looking for PCL_OCTREE
-- Found PCL_OCTREE: /usr/lib/x86_64-linux-gnu/libpcl_octree.so
-- looking for PCL_IO
-- Found PCL_IO: /usr/lib/x86_64-linux-gnu/libpcl_io.so
-- Found PCL: /usr/lib/x86_64-linux-gnu/libboost_system.so;/usr/lib/x86_64-linux-gnu/libboost_filesystem.so;/usr/lib/x86_64-linux-gnu/libboost_thread.so;/usr/lib/x86_64-linux-gnu/libboost_date_time.so;/usr/lib/x86_64-linux-gnu/libboost_iostreams.so;/usr/lib/x86_64-linux-gnu/libboost_serialization.so;/usr/lib/x86_64-linux-gnu/libboost_chrono.so;/usr/lib/x86_64-linux-gnu/libboost_atomic.so;/usr/lib/x86_64-linux-gnu/libboost_regex.so;/usr/lib/x86_64-linux-gnu/libpthread.so;optimized;/usr/lib/x86_64-linux-gnu/libpcl_common.so;debug;/usr/lib/x86_64-linux-gnu/libpcl_common.so;optimized;/usr/lib/x86_64-linux-gnu/libpcl_octree.so;debug;/usr/lib/x86_64-linux-gnu/libpcl_octree.so;/usr/lib/libOpenNI.so;/usr/lib/libOpenNI2.so;vtkImagingStencil;vtkCommonComputationalGeometry;vtkCommonDataModel;vtkCommonMath;vtkCommonCore;vtksys;vtkCommonMisc;vtkCommonSystem;vtkCommonTransforms;vtkImagingCore;vtkCommonExecutionModel;vtkFiltersAMR;vtkFiltersGeneral;vtkFiltersCore;vtkParallelCore;vtkIOLegacy;vtkIOCore;/usr/lib/x86_64-linux-gnu/libz.so;vtkInteractionWidgets;vtkFiltersHybrid;vtkImagingSources;vtkRenderingCore;vtkCommonColor;vtkFiltersExtraction;vtkFiltersStatistics;vtkImagingFourier;vtkalglib;vtkFiltersGeometry;vtkFiltersSources;vtkFiltersModeling;vtkImagingGeneral;vtkImagingHybrid;vtkIOImage;vtkDICOMParser;vtkmetaio;/usr/lib/x86_64-linux-gnu/libjpeg.so;/usr/lib/x86_64-linux-gnu/libpng.so;/usr/lib/x86_64-linux-gnu/libtiff.so;vtkInteractionStyle;vtkRenderingAnnotation;vtkImagingColor;vtkRenderingFreeType;/usr/lib/x86_64-linux-gnu/libfreetype.so;vtkftgl;vtkRenderingVolume;vtkIOParallelNetCDF;vtkParallelMPI;/usr/lib/x86_64-linux-gnu/libnetcdf_c++.so;/usr/lib/x86_64-linux-gnu/libnetcdf.so;/usr/lib/x86_64-linux-gnu/hdf5/serial/lib/libhdf5.so;/usr/lib/x86_64-linux-gnu/libsz.so;/usr/lib/x86_64-linux-gnu/libdl.so;/usr/lib/x86_64-linux-gnu/libm.so;/usr/lib/x86_64-linux-gnu/hdf5/serial/lib/libhdf5_hl.so;vtkRenderingOpenGL;vtkIOLSDyna;vtkIOXML;vtkIOGeometry;/usr/lib/x86_64-linux-gnu/libjsoncpp.so;vtkIOXMLParser;/usr/lib/x86_64-linux-gnu/libexpat.so;vtkLocalExample;vtkInfovisCore;vtkGeovisCore;vtkInfovisLayout;vtkViewsCore;vtkproj4;/usr/lib/x86_64-linux-gnu/libpython2.7.so;vtkTestingGenericBridge;/usr/lib/libgl2ps.so;verdict;vtkIOMovie;/usr/lib/x86_64-linux-gnu/libtheoraenc.so;/usr/lib/x86_64-linux-gnu/libtheoradec.so;/usr/lib/x86_64-linux-gnu/libogg.so;vtkFiltersImaging;vtkIOMINC;vtkRenderingLOD;vtkViewsQt;vtkGUISupportQt;vtkViewsInfovis;vtkChartsCore;vtkRenderingContext2D;vtkRenderingLabel;vtkRenderingImage;vtkFiltersFlowPaths;vtkxdmf2;/usr/lib/x86_64-linux-gnu/libxml2.so;vtkFiltersReebGraph;vtkViewsContext2D;vtkIOXdmf2;vtkIOAMR;vtkRenderingContextOpenGL;vtkImagingStatistics;vtkIOParallel;vtkFiltersParallel;vtkIONetCDF;vtkexoIIc;vtkGUISupportQtOpenGL;vtkIOParallelLSDyna;vtkFiltersParallelGeometry;vtkGUISupportQtWebkit;vtkIOPLY;vtkWrappingTools;vtkFiltersHyperTree;vtkRenderingVolumeOpenGL;vtkIOExodus;vtkIOPostgreSQL;vtkIOSQL;sqlite3;vtkWrappingJava;vtkFiltersParallelFlowPaths;vtkFiltersParallelStatistics;vtkFiltersProgrammable;vtkFiltersParallelImaging;vtkRenderingParallelLIC;vtkRenderingLIC;vtkInteractionImage;vtkFiltersPython;vtkWrappingPythonCore;vtkIOParallelExodus;vtkFiltersGeneric;vtkIOVideo;vtkRenderingQt;vtkFiltersTexture;vtkIOInfovis;vtkGUISupportQtSQL;vtkRenderingFreeTypeOpenGL;vtkInfovisBoostGraphAlgorithms;vtkRenderingGL2PS;vtkIOGeoJSON;vtkFiltersVerdict;vtkViewsGeovis;vtkIOImport;vtkTestingIOSQL;vtkPythonInterpreter;vtkIOODBC;vtkIOEnSight;vtkIOMySQL;vtkRenderingMatplotlib;vtkDomainsChemistry;vtkIOExport;vtkFiltersParallelMPI;vtkIOParallelXML;vtkTestingRendering;vtkIOMPIParallel;vtkParallelMPI4Py;vtkFiltersSMP;vtkFiltersSelection;vtkIOVPIC;VPIC;vtkImagingMath;vtkImagingMorphological;vtkRenderingParallel;vtkRenderingFreeTypeFontConfig;vtkIOFFMPEG;vtkIOMPIImage;vtkIOGDAL;optimized;/usr/lib/x86_64-linux-gnu/libpcl_io.so;debug;/usr/lib/x86_64-linux-gnu/libpcl_io.so;/usr/lib/x86_64-linux-gnu/libboost_system.so;/usr/lib/x86_64-linux-gnu/libboost_filesystem.so;/usr/lib/x86_64-linux-gnu/libboost_thread.so;/usr/lib/x86_64-linux-gnu/libboost_date_time.so;/usr/lib/x86_64-linux-gnu/libboost_iostreams.so;/usr/lib/x86_64-linux-gnu/libboost_serialization.so;/usr/lib/x86_64-linux-gnu/libboost_chrono.so;/usr/lib/x86_64-linux-gnu/libboost_atomic.so;/usr/lib/x86_64-linux-gnu/libboost_regex.so;/usr/lib/x86_64-linux-gnu/libpthread.so;/usr/lib/libOpenNI.so;/usr/lib/libOpenNI2.so;vtkImagingStencil;vtkCommonComputationalGeometry;vtkCommonDataModel;vtkCommonMath;vtkCommonCore;vtksys;vtkCommonMisc;vtkCommonSystem;vtkCommonTransforms;vtkImagingCore;vtkCommonExecutionModel;vtkFiltersAMR;vtkFiltersGeneral;vtkFiltersCore;vtkParallelCore;vtkIOLegacy;vtkIOCore;/usr/lib/x86_64-linux-gnu/libz.so;vtkInteractionWidgets;vtkFiltersHybrid;vtkImagingSources;vtkRenderingCore;vtkCommonColor;vtkFiltersExtraction;vtkFiltersStatistics;vtkImagingFourier;vtkalglib;vtkFiltersGeometry;vtkFiltersSources;vtkFiltersModeling;vtkImagingGeneral;vtkImagingHybrid;vtkIOImage;vtkDICOMParser;vtkmetaio;/usr/lib/x86_64-linux-gnu/libjpeg.so;/usr/lib/x86_64-linux-gnu/libpng.so;/usr/lib/x86_64-linux-gnu/libtiff.so;vtkInteractionStyle;vtkRenderingAnnotation;vtkImagingColor;vtkRenderingFreeType;/usr/lib/x86_64-linux-gnu/libfreetype.so;vtkftgl;vtkRenderingVolume;vtkIOParallelNetCDF;vtkParallelMPI;/usr/lib/x86_64-linux-gnu/libnetcdf_c++.so;/usr/lib/x86_64-linux-gnu/libnetcdf.so;/usr/lib/x86_64-linux-gnu/hdf5/serial/lib/libhdf5.so;/usr/lib/x86_64-linux-gnu/libpthread.so;/usr/lib/x86_64-linux-gnu/libsz.so;/usr/lib/x86_64-linux-gnu/libdl.so;/usr/lib/x86_64-linux-gnu/libm.so;/usr/lib/x86_64-linux-gnu/hdf5/serial/lib/libhdf5_hl.so;vtkRenderingOpenGL;vtkIOLSDyna;vtkIOXML;vtkIOGeometry;/usr/lib/x86_64-linux-gnu/libjsoncpp.so;vtkIOXMLParser;/usr/lib/x86_64-linux-gnu/libexpat.so;vtkLocalExample;vtkInfovisCore;vtkGeovisCore;vtkInfovisLayout;vtkViewsCore;vtkproj4;/usr/lib/x86_64-linux-gnu/libpython2.7.so;vtkTestingGenericBridge;/usr/lib/libgl2ps.so;verdict;vtkIOMovie;/usr/lib/x86_64-linux-gnu/libtheoraenc.so;/usr/lib/x86_64-linux-gnu/libtheoradec.so;/usr/lib/x86_64-linux-gnu/libogg.so;vtkFiltersImaging;vtkIOMINC;vtkRenderingLOD;vtkViewsQt;vtkGUISupportQt;vtkViewsInfovis;vtkChartsCore;vtkRenderingContext2D;vtkRenderingLabel;vtkRenderingImage;vtkFiltersFlowPaths;vtkxdmf2;/usr/lib/x86_64-linux-gnu/libxml2.so;vtkFiltersReebGraph;vtkViewsContext2D;vtkIOXdmf2;vtkIOAMR;vtkRenderingContextOpenGL;vtkImagingStatistics;vtkIOParallel;vtkFiltersParallel;vtkIONetCDF;vtkexoIIc;vtkGUISupportQtOpenGL;vtkIOParallelLSDyna;vtkFiltersParallelGeometry;vtkGUISupportQtWebkit;vtkIOPLY;vtkWrappingTools;vtkFiltersHyperTree;vtkRenderingVolumeOpenGL;vtkIOExodus;vtkIOPostgreSQL;vtkIOSQL;sqlite3;vtkWrappingJava;vtkFiltersParallelFlowPaths;vtkFiltersParallelStatistics;vtkFiltersProgrammable;vtkFiltersParallelImaging;vtkRenderingParallelLIC;vtkRenderingLIC;vtkInteractionImage;vtkFiltersPython;vtkWrappingPythonCore;vtkIOParallelExodus;vtkFiltersGeneric;vtkIOVideo;vtkRenderingQt;vtkFiltersTexture;vtkIOInfovis;vtkGUISupportQtSQL;vtkRenderingFreeTypeOpenGL;vtkInfovisBoostGraphAlgorithms;vtkRenderingGL2PS;vtkIOGeoJSON;vtkFiltersVerdict;vtkViewsGeovis;vtkIOImport;vtkTestingIOSQL;vtkPythonInterpreter;vtkIOODBC;vtkIOEnSight;vtkIOMySQL;vtkRenderingMatplotlib;vtkDomainsChemistry;vtkIOExport;vtkFiltersParallelMPI;vtkIOParallelXML;vtkTestingRendering;vtkIOMPIParallel;vtkParallelMPI4Py;vtkFiltersSMP;vtkFiltersSelection;vtkIOVPIC;VPIC;vtkImagingMath;vtkImagingMorphological;vtkRenderingParallel;vtkRenderingFreeTypeFontConfig;vtkIOFFMPEG;vtkIOMPIImage;vtkIOGDAL (Required is at least version "1.3")
-- Configuring done
-- Generating done
-- Build files have been written to: /home/matt/hdd_home/pcl/tutorials/build
As can quite easily been seen, what is outputted is very different to what is shown in the tutorial.
It does create a build file so I can run make which errors and outputs:
[ 50%] Building CXX object CMakeFiles/pcd_write_test.dir/pcd_write.cpp.o
[100%] Linking CXX executable pcd_write_test
/usr/bin/ld: cannot find -lvtkproj4
collect2: error: ld returned 1 exit status
CMakeFiles/pcd_write_test.dir/build.make:330: recipe for target 'pcd_write_test' failed
make[2]: *** [pcd_write_test] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/pcd_write_test.dir/all' failed
make[1]: *** [CMakeFiles/pcd_write_test.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
I've tried what I can but maybe I lack enough experience to get this all sorted and working.
I also manually installed the package libproj-dev but this did not fix the issue.
Any help would be much appreciated!
The installation is missing python-vtk which is available in the Ubuntu repository.
This contains the required libvtkRenderingPythonTkWidgets package.
Installing it should remove the problem:
sudo apt update
sudo apt install python-vtk
It did for me.
I'm trying to build a program that requires CUDA. To the CMake script I supply:
cmake -D CUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda ..
CUDA is found and CMake runs normally:
staudt ~/workspace/clutbb/cluster/build $ cmake -D CUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda ..
-- Found CUDA: /usr/local/cuda (found version "6.5")
-- Found Intel TBB
-- Boost version: 1.56.0
-- Found the following Boost libraries:
-- iostreams
-- program_options
-- Looking for include file pthread.h
-- Looking for include file pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE
-- Could NOT find SDL (missing: SDL_LIBRARY SDL_INCLUDE_DIR)
-- Configuring done
-- Generating done
-- Build files have been written to: /home/i11/staudt/workspace/clutbb/cluster/build
But then the linker step fails:
staudt ~/workspace/clutbb/cluster/build $ make
[ 69%] Built target cluster
Linking CXX executable clu
CMakeFiles/clu.dir/clu.cpp.o: In function `initCUDA(int&, CUctx_st*&, int const&)':
clu.cpp:(.text+0x517): undefined reference to `cuInit'
clu.cpp:(.text+0x52b): undefined reference to `cuDeviceGet'
clu.cpp:(.text+0x53f): undefined reference to `cuCtxCreate_v2'
clu.cpp:(.text+0x559): undefined reference to `cuDeviceGetName'
clu.cpp:(.text+0x55e): undefined reference to `cuCtxSynchronize'
CMakeFiles/clu.dir/clu.cpp.o: In function `exitCUDA(int&, CUctx_st*&)':
clu.cpp:(.text+0x684): undefined reference to `cuCtxDestroy_v2'
CMakeFiles/clu.dir/clu.cpp.o: In function `main':
clu.cpp:(.text.startup+0x1092): undefined reference to `cuCtxDestroy_v2'
clu.cpp:(.text.startup+0x10d1): undefined reference to `cuCtxSynchronize'
clu.cpp:(.text.startup+0x10e1): undefined reference to `cuCtxSynchronize'
collect2: error: ld returned 1 exit status
make[2]: *** [bin/clu] Fehler 1
make[1]: *** [bin/CMakeFiles/clu.dir/all] Fehler 2
make: *** [all] Fehler 2
The required library is at /usr/local/cuda/lib64/stubs/libcuda.so, but how can I point that out to cmake or make?
In the archive you have now posted, there are multiple project hierarchies. The actual error you have posted in the question is occurring during compile and linking of the clu project based on clu.cpp in the clutbb/cluster/bin directory.
In this same directory, there is a CMakeLists.txt file. This file governs this particular level of the project hierarchy.
In this particular CMakeLists.txt file, there is the following section:
cuda_add_executable(clu clu.cpp)
target_link_libraries(clu ${CUDA_LIBRARY} ${TBB_LIBRARY} ${Boost_LIBRARIES} rt)
target_link_libraries(clu cluster)
Try modifying the middle line above to:
target_link_libraries(clu ${CUDA_LIBRARY} ${TBB_LIBRARY} ${Boost_LIBRARIES} rt cuda)
This should fix the missing -lcuda in the linker command line. It may still be necessary to give it the path to libcuda.so on your machine, but it may not be necessary, depending on how your machine environment is set up.
The correct way of doing this on CMake 3.17+ is to use the FindCUDAToolkit module, like so:
find_package(CUDAToolkit REQUIRED)
target_link_libraries(my_target PRIVATE CUDA::cudart CUDA::cuda_driver)
The CUDA::cuda_driver target is equivalent to -lcuda when the linker would find it, and is otherwise an absolute path to the correct library. You should avoid adding system libraries via target_link_libraries to ensure portability.
If you have an older version (CMake 3.0+), you can use the (now-deprecated) FindCUDA module to imitate the 3.17 module, like so:
find_package(CUDA REQUIRED)
# Do what the new package does
find_library(CUDA_DRIVER_LIBRARY
NAMES cuda_driver cuda
HINTS ${CUDA_TOOLKIT_ROOT_DIR}
ENV CUDA_PATH
PATH_SUFFIXES nvidia/current lib64 lib/x64 lib)
if (NOT CUDA_DRIVER_LIBRARY)
# Don't try any stub directories until we have exhausted all other search locations.
find_library(CUDA_DRIVER_LIBRARY
NAMES cuda_driver cuda
HINTS ${CUDA_TOOLKIT_ROOT_DIR}
ENV CUDA_PATH
PATH_SUFFIXES lib64/stubs lib/x64/stubs lib/stubs stubs)
endif ()
mark_as_advanced(CUDA_DRIVER_LIBRARY)
##
target_include_directories(my_target PRIVATE ${CUDA_INCLUDE_DIRS})
target_link_libraries(my_target PRIVATE ${CUDA_LIBRARIES} ${CUDA_DRIVER_LIBRARY})
This is adapted from the official sources, here.
The C++ file with host calls doesnt know it needs to link to libcudart. You have to explicitly set dependencies for the file/binary that file is in, eg.
target_link_libraries(clu ${CUDA_LIBRARIES})
The above response is slightly wrong. It looks like libcuda.so is installed in unexpected location for whatever reason. You can try setting CMAKE_LIBRARY_PATH or/and CUDA_LIB_PATH to that path.
The CUDA_LIB_PATH needs to be set outside cmake I think, eg export CUDA_LIB_PATH=/usr/local/cuda/lib64/stubs/