CMake wont link my library, make file does - c++

Background
I recently downloaded a lib called "RayLib" for c and c++. I added the mingw includes and libs into my project and well, now i wanna link them.
The problem
For some reason, cmake does not link the static lib. When i try to run the project, it tells me that there still undefined references to "InitWindow" and "SetTargetFPS" :
====================[ Build | Engine | Debug ]==================================
C:\Users\Lars\AppData\Local\JetBrains\Toolbox\apps\CLion\ch-0\203.7148.70\bin\cmake\win\bin\cmake.exe --build C:\Users\Lars\CLionProjects\Engine\cmake-build-debug --target Engine -- -j 9
C:\Users\Lars\AppData\Local\JetBrains\Toolbox\apps\CLion\ch-0\203.7148.70\bin\cmake\win\bin\cmake.exe -SC:\Users\Lars\CLionProjects\Engine -BC:\Users\Lars\CLionProjects\Engine\cmake-build-debug --check-build-system CMakeFiles\Makefile.cmake 0
C:/Users/Lars/Desktop/Development/MinGW/bin/mingw32-make.exe -f CMakeFiles\Makefile2 Engine
mingw32-make.exe[1]: Entering directory 'C:/Users/Lars/CLionProjects/Engine/cmake-build-debug'
C:\Users\Lars\AppData\Local\JetBrains\Toolbox\apps\CLion\ch-0\203.7148.70\bin\cmake\win\bin\cmake.exe -SC:\Users\Lars\CLionProjects\Engine -BC:\Users\Lars\CLionProjects\Engine\cmake-build-debug --check-build-system CMakeFiles\Makefile.cmake 0
C:\Users\Lars\AppData\Local\JetBrains\Toolbox\apps\CLion\ch-0\203.7148.70\bin\cmake\win\bin\cmake.exe -E cmake_progress_start C:\Users\Lars\CLionProjects\Engine\cmake-build-debug\CMakeFiles 2
C:/Users/Lars/Desktop/Development/MinGW/bin/mingw32-make.exe -f CMakeFiles\Makefile2 CMakeFiles/Engine.dir/all
mingw32-make.exe[2]: Entering directory 'C:/Users/Lars/CLionProjects/Engine/cmake-build-debug'
C:/Users/Lars/Desktop/Development/MinGW/bin/mingw32-make.exe -f CMakeFiles\Engine.dir\build.make CMakeFiles/Engine.dir/depend
mingw32-make.exe[3]: Entering directory 'C:/Users/Lars/CLionProjects/Engine/cmake-build-debug'
C:\Users\Lars\AppData\Local\JetBrains\Toolbox\apps\CLion\ch-0\203.7148.70\bin\cmake\win\bin\cmake.exe -E cmake_depends "MinGW Makefiles" C:\Users\Lars\CLionProjects\Engine C:\Users\Lars\CLionProjects\Engine C:\Users\Lars\CLionProjects\Engine\cmake-build-debug C:\Users\Lars\CLionProjects\Engine\cmake-build-debug C:\Users\Lars\CLionProjects\Engine\cmake-build-debug\CMakeFiles\Engine.dir\DependInfo.cmake --color=
mingw32-make.exe[3]: Leaving directory 'C:/Users/Lars/CLionProjects/Engine/cmake-build-debug'
C:/Users/Lars/Desktop/Development/MinGW/bin/mingw32-make.exe -f CMakeFiles\Engine.dir\build.make CMakeFiles/Engine.dir/build
mingw32-make.exe[3]: Entering directory 'C:/Users/Lars/CLionProjects/Engine/cmake-build-debug'
[ 50%] Linking CXX executable Engine.exe
C:\Users\Lars\AppData\Local\JetBrains\Toolbox\apps\CLion\ch-0\203.7148.70\bin\cmake\win\bin\cmake.exe -E cmake_link_script CMakeFiles\Engine.dir\link.txt --verbose=1
C:\Users\Lars\AppData\Local\JetBrains\Toolbox\apps\CLion\ch-0\203.7148.70\bin\cmake\win\bin\cmake.exe -E rm -f CMakeFiles\Engine.dir/objects.a
C:\Users\Lars\Desktop\Development\MinGW\bin\ar.exe cr CMakeFiles\Engine.dir/objects.a #CMakeFiles\Engine.dir\objects1.rsp
C:\Users\Lars\Desktop\Development\MinGW\bin\g++.exe -Wall -std=c++17 -g -Wl,--whole-archive CMakeFiles\Engine.dir/objects.a -Wl,--no-whole-archive -o Engine.exe -Wl,--out-implib,libEngine.dll.a -Wl,--major-image-version,0,--minor-image-version,0 #CMakeFiles\Engine.dir\linklibs.rsp
c:/users/lars/desktop/development/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: CMakeFiles\Engine.dir/objects.a(main.cpp.obj): in function `main':
C:/Users/Lars/CLionProjects/Engine/main.cpp:22: undefined reference to `InitWindow'
c:/users/lars/desktop/development/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: C:/Users/Lars/CLionProjects/Engine/main.cpp:24: undefined reference to `SetTargetFPS'
c:/users/lars/desktop/development/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: C:/Users/Lars/CLionProjects/Engine/main.cpp:28: undefined reference to `WindowShouldClose'
c:/users/lars/desktop/development/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: C:/Users/Lars/CLionProjects/Engine/main.cpp:37: undefined reference to `BeginDrawing'
c:/users/lars/desktop/development/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: C:/Users/Lars/CLionProjects/Engine/main.cpp:39: undefined reference to `ClearBackground'
c:/users/lars/desktop/development/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: C:/Users/Lars/CLionProjects/Engine/main.cpp:41: undefined reference to `DrawText'
c:/users/lars/desktop/development/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: C:/Users/Lars/CLionProjects/Engine/main.cpp:43: undefined reference to `EndDrawing'
c:/users/lars/desktop/development/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: C:/Users/Lars/CLionProjects/Engine/main.cpp:49: undefined reference to `CloseWindow'
collect2.exe: error: ld returned 1 exit status
mingw32-make.exe[3]: *** [Engine.exe] Error 1
mingw32-make.exe[2]: *** [CMakeFiles/Engine.dir/all] Error 2
mingw32-make.exe[1]: *** [CMakeFiles/Engine.dir/rule] Error 2
mingw32-make.exe: *** [Engine] Error 2
CMakeFiles\Engine.dir\build.make:108: recipe for target 'Engine.exe' failed
mingw32-make.exe[3]: Leaving directory 'C:/Users/Lars/CLionProjects/Engine/cmake-build-debug'
CMakeFiles\Makefile2:97: recipe for target 'CMakeFiles/Engine.dir/all' failed
mingw32-make.exe[2]: Leaving directory 'C:/Users/Lars/CLionProjects/Engine/cmake-build-debug'
CMakeFiles\Makefile2:104: recipe for target 'CMakeFiles/Engine.dir/rule' failed
mingw32-make.exe[1]: Leaving directory 'C:/Users/Lars/CLionProjects/Engine/cmake-build-debug'
Makefile:140: recipe for target 'Engine' failed
My cmake file looks like this...
cmake_minimum_required(VERSION 3.17)
project(Engine)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_VERBOSE_MAKEFILE ON)
include_directories(include)
include_directories(libs)
link_directories(libs)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -std=c++17")
add_executable(Engine main.cpp)
target_link_libraries(Engine raylib)
My own written make file, located in the root which simply adds a -I include, -L libs and -lraylib is able to compile this project.
main: main.o
g++ -I include ... -o main main.o -L libs -lraylib
main.o: main.cpp
g++ -I include ... -c main.cpp -L libs -lraylib
Question
Why exactly does target_link_libraries not work ? Why doesnt it link my .a file located in libs/ ? What am i doing wrong here ? Why isnt Cmake able to link my project, but my own makefile is able to do it ?
Any help is welcome !

From the documentation about the command link_directories():
This command is rarely necessary and should be avoided where there are other choices. Prefer to pass full absolute paths to libraries where possible, since this ensures the correct library will always be linked. The find_library() command provides the full path, which can generally be used directly in calls to target_link_libraries().
find_library() is hopefully sufficient by itself.

Related

Make failing with not used function

I am trying to build my code.
After I do cmake .. from a build directory I do make -j8 and I get
[ 90%] Building CXX object common/CMakeFiles/common.dir/src/utils/path_util.cpp.o
[ 95%] Linking CXX executable myproj
CMakeFiles/myproj.dir/main.cpp.o: In function `cv::String::~String()':
main.cpp:(.text._ZN2cv6StringD2Ev[_ZN2cv6StringD5Ev]+0x14): undefined reference to `cv::String::deallocate()'
CMakeFiles/myproj.dir/main.cpp.o: In function `cv::String::operator=(cv::String const&)':
main.cpp:(.text._ZN2cv6StringaSERKS0_[_ZN2cv6StringaSERKS0_]+0x28): undefined reference to `cv::String::deallocate()'
collect2: error: ld returned 1 exit status
CMakeFiles/myproj.dir/build.make:95: recipe for target 'myproj' failed
make[2]: *** [myproj] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/myproj.dir/all' failed
make[1]: *** [CMakeFiles/myproj.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
The curious thing is that nowhere in the code I use cv::String.
I have also put
#Search for dependencies
set(MIN_OPENCV_VERSION "3.4.11" CACHE STRING "OpenCV version")
find_package(OpenCV ${MIN_OPENCV_VERSION} REQUIRED
COMPONENTS core
PATHS /usr/local/opencv-${MIN_OPENCV_VERSION}
NO_DEFAULT_PATH
)
in several CMakeLists.txt files and cmake finds opencv
What could be the problem?
EDIT
I set the VERBOSE environment variable to 1 as stated here
and I got
[ 90%] Building CXX object common/CMakeFiles/common.dir/src/utils/path_util.cpp.o
cd /home/user/ws/src/build/common && /usr/bin/c++ -I/usr/local/include/eigen3 -isystem /usr/local/opencv-3.4.11/include -isystem /usr/local/opencv-3.4.11/include/opencv -I/home/user/ws/src/common/include -I/home/user/ws/src/common/src -isystem /usr/local -fPIC -o CMakeFiles/common.dir/src/utils/path_util.cpp.o -c /home/user/ws/src/common/src/utils/path_util.cpp
[ 95%] Linking CXX executable road_info
/usr/bin/cmake -E cmake_link_script CMakeFiles/myproj.dir/link.txt --verbose=1
/usr/bin/c++ -rdynamic CMakeFiles/myproj.dir/main.cpp.o -o myproj mainpub_lib/mainpub.a
CMakeFiles/myproj.dir/main.cpp.o: In function `cv::String::~String()':
main.cpp:(.text._ZN2cv6StringD2Ev[_ZN2cv6StringD5Ev]+0x14): undefined reference to `cv::String::deallocate()'
CMakeFiles/myproj.dir/main.cpp.o: In function `cv::String::operator=(cv::String const&)':
main.cpp:(.text._ZN2cv6StringaSERKS0_[_ZN2cv6StringaSERKS0_]+0x28): undefined reference to `cv::String::deallocate()'
collect2: error: ld returned 1 exit status
CMakeFiles/myproj.dir/build.make:95: recipe for target 'myproj' failed
make[2]: *** [myproj] Error 1
make[2]: Leaving directory '/home/user/ws/src/build'
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/myproj.dir/all' failed
make[1]: *** [CMakeFiles/myproj.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
First, thanks #fabian for the help and pointers
I finally realized that the problem was not in my main.cpp but in a hpp file that main calls. This one.hpp file included another hpp file that was the one that caused the problem (When I commented it, the problem disapeared)
So what I did was change the CMakeLists.txt of the second level (the one dealing with the problematic hpp file) and added
target_link_libraries(mainpub PRIVATE ${OpenCV_LIBS})
With this the problem was solved
To allow for a verbose make I did export VERBOSE=1 because my make version is old. With the verbose output I could see that mainpub was the only library linked
What strikes me strange is that mainpub was apparently being built even with the problem instead the main build was signaled as problematic

CMake fatal error: CMakeFiles/<path>.dir/main.cpp.d: No such file or directory

I am trying to compile a simple C++ program with CMake on Ubuntu 18.04, but all of my CMake projects fails when I run the make command.
Below is a minimum working example.
The directory structure looks like this:
- project directory
|-build
|-main.cpp
|-CMakeLists.txt
main.cpp
int main(void)
{
return 0;
}
CMakeLists.txt
cmake_minimum_required (VERSION 3.1)
project(Test-Project)
add_executable(a
main.cpp
)
target_compile_options(a
PUBLIC -Wall -o -std=c++11
)
Building
cd build
cmake ../ # this works without any error
make # this fails
Error
[ 50%] Building CXX object CMakeFiles/a.dir/main.cpp.o
cc1plus: fatal error: CMakeFiles/a.dir/main.cpp.d: No such file or directory
compilation terminated.
CMakeFiles/a.dir/build.make:75: recipe for target 'CMakeFiles/a.dir/main.cpp.o' failed
make[2]: *** [CMakeFiles/a.dir/main.cpp.o] Error 1
CMakeFiles/Makefile2:82: recipe for target 'CMakeFiles/a.dir/all' failed
make[1]: *** [CMakeFiles/a.dir/all] Error 2
Makefile:90: recipe for target 'all' failed
make: *** [all] Error 2
I get this error when try to compile any CMake based program on the system.
However, if I just used g++ directly to compile the program, it compiles without any complaints.
For example:
g++ ../main.cpp
compiles the program, and runs the program without any errors.
cmake --version: cmake version 3.22.1
g++ --version: g++ (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0
g++ -print-prog-name=cc1plus: /usr/lib/gcc/x86_64-linux-gnu/7/cc1plus
uname -a: Linux <computer name> 5.4.0-91-generic #102~18.04.1-Ubuntu SMP <date+time> x86_64 x86_64 x86_64 GNU/Linux
EDIT
Terminal output when compiled with make VERBOSE=1:
/home/kani/.local/lib/python2.7/site-packages/cmake/data/bin/cmake -S/home/kani/Documents/test -B/home/kani/Documents/test/build --check-build-system CMakeFiles/Makefile.cmake 0
/home/kani/.local/lib/python2.7/site-packages/cmake/data/bin/cmake -E cmake_progress_start /home/kani/Documents/test/build/CMakeFiles /home/kani/Documents/test/build//CMakeFiles/progress.marks
make -f CMakeFiles/Makefile2 all
make[1]: Entering directory '/home/kani/Documents/test/build'
make -f CMakeFiles/a.dir/build.make CMakeFiles/a.dir/depend
make[2]: Entering directory '/home/kani/Documents/test/build'
cd /home/kani/Documents/test/build && /home/kani/.local/lib/python2.7/site-packages/cmake/data/bin/cmake -E cmake_depends "Unix Makefiles" /home/kani/Documents/test /home/kani/Documents/test /home/kani/Documents/test/build /home/kani/Documents/test/build /home/kani/Documents/test/build/CMakeFiles/a.dir/DependInfo.cmake --color=
make[2]: Leaving directory '/home/kani/Documents/test/build'
make -f CMakeFiles/a.dir/build.make CMakeFiles/a.dir/build
make[2]: Entering directory '/home/kani/Documents/test/build'
[ 50%] Building CXX object CMakeFiles/a.dir/main.cpp.o
/usr/bin/c++ -Wall -o -std=c++11 -MD -MT CMakeFiles/a.dir/main.cpp.o -MF CMakeFiles/a.dir/main.cpp.o.d -o CMakeFiles/a.dir/main.cpp.o -c /home/kani/Documents/test/main.cpp
cc1plus: fatal error: CMakeFiles/a.dir/main.cpp.d: No such file or directory
compilation terminated.
CMakeFiles/a.dir/build.make:75: recipe for target 'CMakeFiles/a.dir/main.cpp.o' failed
make[2]: *** [CMakeFiles/a.dir/main.cpp.o] Error 1
make[2]: Leaving directory '/home/kani/Documents/test/build'
CMakeFiles/Makefile2:82: recipe for target 'CMakeFiles/a.dir/all' failed
make[1]: *** [CMakeFiles/a.dir/all] Error 2
make[1]: Leaving directory '/home/kani/Documents/test/build'
Makefile:90: recipe for target 'all' failed
make: *** [all] Error 2
Despite the error message about absent .d file seems to be internal to CMake (such files are used for collect header dependencies generated by the compiler), its usual reason is specifying some output-controlling compiler options in the CMakeLists.txt.
In your case it is -o option which damages the command line generated by CMake. CMake by itself uses this option for specify object file which will be created as a result of the compilation. So adding another -o is wrong.

CMake + freeglut3: cannot find usbhid.h

System: I am using Linux Mint 17.3 as VB-Guest on a Max OS 10.11.3 system.
Problem: Id like to compile freeglut3.0.0
Issue: cmake gives me an fatal error: usbhid.h: No such file or directory
Hello,
The problem is, that even after installing all dependencies I cannot find this file on my system. After researching I found out that it has something to do with some usb-drivers. Could it be that it has something to do with The VB-System with no "actual" usb-hardware?
or is there a package that I am missing.
I installed libgl1-mesa-dev, libx11-dev, libxrandr-dev and libxi-dev
Here I attached the CMakeError.log
Determining if files usbhid.h exist failed with the following output:
Change Dir: /opt/freeglut-3.0.0/CMakeFiles/CMakeTmp
Run Build Command:/usr/bin/make "cmTryCompileExec2451224769/fast"
/usr/bin/make -f CMakeFiles/cmTryCompileExec2451224769.dir/build.make CMakeFiles/cmTryCompileExec2451224769.dir/build
make[1]: Entering directory `/opt/freeglut-3.0.0/CMakeFiles/CMakeTmp'
/usr/bin/cmake -E cmake_progress_report /opt/freeglut-3.0.0/CMakeFiles/CMakeTmp/CMakeFiles 1
Building C object CMakeFiles/cmTryCompileExec2451224769.dir/CheckIncludeFiles.c.o
/usr/bin/cc -Wall -pedantic -o CMakeFiles/cmTryCompileExec2451224769.dir/CheckIncludeFiles.c.o -c /opt/freeglut-3.0.0/CMakeFiles/CMakeTmp/CheckIncludeFiles.c
/opt/freeglut-3.0.0/CMakeFiles/CMakeTmp/CheckIncludeFiles.c:2:20: fatal error: usbhid.h: No such file or directory
#include <usbhid.h>
^
compilation terminated.
make[1]: Leaving directory `/opt/freeglut-3.0.0/CMakeFiles/CMakeTmp'
make[1]: *** [CMakeFiles/cmTryCompileExec2451224769.dir/CheckIncludeFiles.c.o] Error 1
make: *** [cmTryCompileExec2451224769/fast] Error 2
Source:
/* */
#include <usbhid.h>
int main(){return 0;}
Determining if the function XParseGeometry exists failed with the following output:
Change Dir: /opt/freeglut-3.0.0/CMakeFiles/CMakeTmp
Run Build Command:/usr/bin/make "cmTryCompileExec2875944840/fast"
/usr/bin/make -f CMakeFiles/cmTryCompileExec2875944840.dir/build.make CMakeFiles/cmTryCompileExec2875944840.dir/build
make[1]: Entering directory `/opt/freeglut-3.0.0/CMakeFiles/CMakeTmp'
/usr/bin/cmake -E cmake_progress_report /opt/freeglut-3.0.0/CMakeFiles/CMakeTmp/CMakeFiles 1
Building C object CMakeFiles/cmTryCompileExec2875944840.dir/CheckFunctionExists.c.o
/usr/bin/cc -Wall -pedantic -DCHECK_FUNCTION_EXISTS=XParseGeometry -o CMakeFiles/cmTryCompileExec2875944840.dir/CheckFunctionExists.c.o -c /usr/share/cmake-2.8/Modules/CheckFunctionExists.c
Linking C executable cmTryCompileExec2875944840
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTryCompileExec2875944840.dir/link.txt --verbose=1
/usr/bin/cc -Wall -pedantic -DCHECK_FUNCTION_EXISTS=XParseGeometry CMakeFiles/cmTryCompileExec2875944840.dir/CheckFunctionExists.c.o -o cmTryCompileExec2875944840 -rdynamic -lm
CMakeFiles/cmTryCompileExec2875944840.dir/CheckFunctionExists.c.o: In function `main':
CheckFunctionExists.c:(.text+0x15): undefined reference to `XParseGeometry'
collect2: error: ld returned 1 exit status
make[1]: Leaving directory `/opt/freeglut-3.0.0/CMakeFiles/CMakeTmp'
make[1]: *** [cmTryCompileExec2875944840] Error 1
make: *** [cmTryCompileExec2875944840/fast] Error 2
I don't know how to find a solution for myself so i ask it here.
Thanks in advance
usbhid.h : Please install ``libusbhid-dev´´ : $ sudo apt-get install libusbhid-dev

OCCI C++ app undefined reference

I started here but so much has changed I thought it best to start a new question, especially since I think the CMake issue in the that question is solved.
Background
I'm trying setup a basic shell of a project that involves connecting a C++ midtier to an Oracle 12c database.
Environment
1. MinGW-64 (x86_64-4.9.1-release-win32-sjlj-rt_v3-rev2)
2. Windows 7 64-bit
3. CLion 2016.1.1 (so I'm using CMake 3.5.1)
4. All of the OCCI DLLs are in system32.
5. Both the libs and the dlls are in C:/Users/hurst/libs
CMakeLists.txt
cmake_minimum_required(VERSION 3.4)
project(Oracle)
#set(CMAKE_VERBOSE_MAKEFILE ON)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
set(CMAKE_PREFIX_PATH C:/Users/hurst/libs)
find_library(OCCI1 oraociei12)
find_library(OCCI2 oci)
find_library(OCCI3 orannzsbb12)
find_library(OCCI4 oraocci12)
set(SOURCE_FILES
src/main.cpp
include/occi.h)
add_executable(Oracle ${SOURCE_FILES})
target_link_libraries(Oracle ${OCCI1} ${OCCI2} ${OCCI3} ${OCCI4})
Code
#include <occi.h>
using namespace oracle::occi;
int main()
{
Environment *env = Environment::createEnvironment();
Environment::terminateEnvironment(env);
}
Error
"C:\Program Files (x86)\JetBrains\CLion 2016.1\bin\cmake\bin\cmake.exe" --build C:\Users\hurst\.CLion2016.1\system\cmake\generated\Oracle-6ad0652d\6ad0652d\Debug --target Oracle -- -j 8
[ 50%] Linking CXX executable C:\Users\hurst\ClionProjects\Oracle\output\Debug\Oracle.exe
CMakeFiles\Oracle.dir/objects.a(main.cpp.obj): In function `main':
C:/Users/hurst/ClionProjects/Oracle/src/main.cpp:7: undefined reference to `oracle::occi::Environment::createEnvironment(oracle::occi::Environment::Mode, void*, void* (*)(void*, unsigned long long), void* (*)(void*, void*, unsigned long long), void (*)(void*, void*))'
C:/Users/hurst/ClionProjects/Oracle/src/main.cpp:8: undefined reference to `oracle::occi::Environment::terminateEnvironment(oracle::occi::Environment*)'
collect2.exe: error: ld returned 1 exit status
CMakeFiles\Oracle.dir\build.make:100: recipe for target 'C:/Users/hurst/ClionProjects/Oracle/output/Debug/Oracle.exe' failed
mingw32-make.exe[3]: *** [C:/Users/hurst/ClionProjects/Oracle/output/Debug/Oracle.exe] Error 1
CMakeFiles\Makefile2:66: recipe for target 'CMakeFiles/Oracle.dir/all' failed
mingw32-make.exe[2]: *** [CMakeFiles/Oracle.dir/all] Error 2
mingw32-make.exe[1]: *** [CMakeFiles/Oracle.dir/rule] Error 2
mingw32-make.exe: *** [Oracle] Error 2
CMakeFiles\Makefile2:78: recipe for target 'CMakeFiles/Oracle.dir/rule' failed
makefile:117: recipe for target 'Oracle' failed
Any suggestions? Thanks.
Edit
As suggested here is the verbose error output:
"C:\Program Files (x86)\JetBrains\CLion 2016.1\bin\cmake\bin\cmake.exe" --build C:\Users\hurst\.CLion2016.1\system\cmake\generated\Oracle-6ad0652d\6ad0652d\Debug --target Oracle -- -j 8
"C:\Program Files (x86)\JetBrains\CLion 2016.1\bin\cmake\bin\cmake.exe" -HC:\Users\hurst\ClionProjects\Oracle -BC:\Users\hurst\.CLion2016.1\system\cmake\generated\Oracle-6ad0652d\6ad0652d\Debug --check-build-system CMakeFiles\Makefile.cmake 0
C:/Users/hurst/Downloads/x86_64-4.9.1-release-win32-sjlj-rt_v3-rev2/mingw64/bin/mingw32-make.exe -f CMakeFiles\Makefile2 Oracle
mingw32-make.exe[1]: Entering directory 'C:/Users/hurst/.CLion2016.1/system/cmake/generated/Oracle-6ad0652d/6ad0652d/Debug'
"C:\Program Files (x86)\JetBrains\CLion 2016.1\bin\cmake\bin\cmake.exe" -HC:\Users\hurst\ClionProjects\Oracle -BC:\Users\hurst\.CLion2016.1\system\cmake\generated\Oracle-6ad0652d\6ad0652d\Debug --check-build-system CMakeFiles\Makefile.cmake 0
"C:\Program Files (x86)\JetBrains\CLion 2016.1\bin\cmake\bin\cmake.exe" -E cmake_progress_start C:\Users\hurst\.CLion2016.1\system\cmake\generated\Oracle-6ad0652d\6ad0652d\Debug\CMakeFiles 2
C:/Users/hurst/Downloads/x86_64-4.9.1-release-win32-sjlj-rt_v3-rev2/mingw64/bin/mingw32-make.exe -f CMakeFiles\Makefile2 CMakeFiles/Oracle.dir/all
mingw32-make.exe[2]: Entering directory 'C:/Users/hurst/.CLion2016.1/system/cmake/generated/Oracle-6ad0652d/6ad0652d/Debug'
C:/Users/hurst/Downloads/x86_64-4.9.1-release-win32-sjlj-rt_v3-rev2/mingw64/bin/mingw32-make.exe -f CMakeFiles\Oracle.dir\build.make CMakeFiles/Oracle.dir/depend
mingw32-make.exe[3]: Entering directory 'C:/Users/hurst/.CLion2016.1/system/cmake/generated/Oracle-6ad0652d/6ad0652d/Debug'
"C:\Program Files (x86)\JetBrains\CLion 2016.1\bin\cmake\bin\cmake.exe" -E cmake_depends "MinGW Makefiles" C:\Users\hurst\ClionProjects\Oracle C:\Users\hurst\ClionProjects\Oracle C:\Users\hurst\.CLion2016.1\system\cmake\generated\Oracle-6ad0652d\6ad0652d\Debug C:\Users\hurst\.CLion2016.1\system\cmake\generated\Oracle-6ad0652d\6ad0652d\Debug C:\Users\hurst\.CLion2016.1\system\cmake\generated\Oracle-6ad0652d\6ad0652d\Debug\CMakeFiles\Oracle.dir\DependInfo.cmake --color=
mingw32-make.exe[3]: Leaving directory 'C:/Users/hurst/.CLion2016.1/system/cmake/generated/Oracle-6ad0652d/6ad0652d/Debug'
C:/Users/hurst/Downloads/x86_64-4.9.1-release-win32-sjlj-rt_v3-rev2/mingw64/bin/mingw32-make.exe -f CMakeFiles\Oracle.dir\build.make CMakeFiles/Oracle.dir/build
mingw32-make.exe[3]: Entering directory 'C:/Users/hurst/.CLion2016.1/system/cmake/generated/Oracle-6ad0652d/6ad0652d/Debug'
[ 50%] Linking CXX executable C:\Users\hurst\ClionProjects\Oracle\output\Debug\Oracle.exe
"C:\Program Files (x86)\JetBrains\CLion 2016.1\bin\cmake\bin\cmake.exe" -E cmake_link_script CMakeFiles\Oracle.dir\link.txt --verbose=1
"C:\Program Files (x86)\JetBrains\CLion 2016.1\bin\cmake\bin\cmake.exe" -E remove -f CMakeFiles\Oracle.dir/objects.a
C:\Users\hurst\Downloads\x86_64-4.9.1-release-win32-sjlj-rt_v3-rev2\mingw64\bin\ar.exe cr CMakeFiles\Oracle.dir/objects.a #CMakeFiles\Oracle.dir\objects1.rsp
C:\Users\hurst\Downloads\x86_64-4.9.1-release-win32-sjlj-rt_v3-rev2\mingw64\bin\g++.exe -std=c++11 -g -Wl,--whole-archive CMakeFiles\Oracle.dir/objects.a -Wl,--no-whole-archive -o C:\Users\hurst\ClionProjects\Oracle\output\Debug\Oracle.exe -Wl,--out-implib,C:\Users\hurst\ClionProjects\Oracle\output\Debug\libOracle.dll.a -Wl,--major-image-version,0,--minor-image-version,0 #CMakeFiles\Oracle.dir\linklibs.rsp
CMakeFiles\Oracle.dir/objects.a(main.cpp.obj): In function `main':
C:/Users/hurst/ClionProjects/Oracle/src/main.cpp:7: undefined reference to `oracle::occi::Environment::createEnvironment(oracle::occi::Environment::Mode, void*, void* (*)(void*, unsigned long long), void* (*)(void*, void*, unsigned long long), void (*)(void*, void*))'
C:/Users/hurst/ClionProjects/Oracle/src/main.cpp:8: undefined reference to `oracle::occi::Environment::terminateEnvironment(oracle::occi::Environment*)'
collect2.exe: error: ld returned 1 exit status
mingw32-make.exe[3]: *** [C:/Users/hurst/ClionProjects/Oracle/output/Debug/Oracle.exe] Error 1
mingw32-make.exe[2]: *** [CMakeFiles/Oracle.dir/all] Error 2
CMakeFiles\Oracle.dir\build.make:103: recipe for target 'C:/Users/hurst/ClionProjects/Oracle/output/Debug/Oracle.exe' failed
mingw32-make.exe[3]: Leaving directory 'C:/Users/hurst/.CLion2016.1/system/cmake/generated/Oracle-6ad0652d/6ad0652d/Debug'
CMakeFiles\Makefile2:69: recipe for target 'CMakeFiles/Oracle.dir/all' failed
mingw32-make.exe[2]: Leaving directory 'C:/Users/hurst/.CLion2016.1/system/cmake/generated/Oracle-6ad0652d/6ad0652d/Debug'
CMakeFiles\Makefile2:81: recipe for target 'CMakeFiles/Oracle.dir/rule' failed
mingw32-make.exe[1]: Leaving directory 'C:/Users/hurst/.CLion2016.1/system/cmake/generated/Oracle-6ad0652d/6ad0652d/Debug'
makefile:120: recipe for target 'Oracle' failed
mingw32-make.exe[1]: *** [CMakeFiles/Oracle.dir/rule] Error 2
mingw32-make.exe: *** [Oracle] Error 2
Edit
Based on some reading I've been doing on another SO answer I broke up the target_link_libraries() call so that it's one library per call:
target_link_libraries(Oracle ${OCCI1})
target_link_libraries(Oracle ${OCCI2})
target_link_libraries(Oracle ${OCCI3})
target_link_libraries(Oracle ${OCCI4})
I then tried to run it by moving ${OCCI2} up/down one and see if it succeeds (i.e. 1234, 2134, 1324, 1342) since ${OCCI2} is the OCI lib which represents the base C API of the Oracle interface. It didn't work, same error.

CMake fails compilation

I am trying to compile cocos2d-x 3.5 on openSUSE 13.2 and i get the following error in .log file:
Determining if the pthread_create exist failed with the following output:
Change Dir: /home/humman/android-dev/cocos2d-x-3.5/cocos2d-x-3.5/build/linux-build/CMakeFiles/CMakeTmp
Run Build Command:"/usr/bin/gmake" "cmTryCompileExec846787943/fast"
/usr/bin/gmake -f CMakeFiles/cmTryCompileExec846787943.dir/build.make CMakeFiles/cmTryCompileExec846787943.dir/build
gmake[1]: Entering directory '/home/humman/android-dev/cocos2d-x-3.5/cocos2d-x-3.5/build/linux-build/CMakeFiles/CMakeTmp'
/usr/bin/cmake -E cmake_progress_report /home/humman/android-dev/cocos2d-x-3.5/cocos2d-x-3.5/build/linux-build/CMakeFiles/CMakeTmp/CMakeFiles 1
Building C object CMakeFiles/cmTryCompileExec846787943.dir/CheckSymbolExists.c.o
/usr/bin/cc -fno-exceptions -std=c99 -o CMakeFiles/cmTryCompileExec846787943.dir/CheckSymbolExists.c.o -c /home/humman/android-dev/cocos2d-x-3.5/cocos2d-x-3.5/build/linux-build/CMakeFiles/CMakeTmp/CheckSymbolExists.c
Linking C executable cmTryCompileExec846787943
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTryCompileExec846787943.dir/link.txt --verbose=1
/usr/bin/cc -fno-exceptions -std=c99 CMakeFiles/cmTryCompileExec846787943.dir/CheckSymbolExists.c.o -o cmTryCompileExec846787943 -rdynamic
CMakeFiles/cmTryCompileExec846787943.dir/CheckSymbolExists.c.o: In function `main':
CheckSymbolExists.c:(.text+0x16): undefined reference to `pthread_create'
collect2: error: ld returned 1 exit status
CMakeFiles/cmTryCompileExec846787943.dir/build.make:88: recipe for target 'cmTryCompileExec846787943' failed
gmake[1]: *** [cmTryCompileExec846787943] Error 1
gmake[1]: Leaving directory '/home/humman/android-dev/cocos2d-x-3.5/cocos2d-x-3.5/build/linux-build/CMakeFiles/CMakeTmp'
Makefile:118: recipe for target 'cmTryCompileExec846787943/fast' failed
gmake: *** [cmTryCompileExec846787943/fast] Error 2
File /home/humman/android-dev/cocos2d-x-3.5/cocos2d-x-3.5/build/linux-build/CMakeFiles/CMakeTmp/CheckSymbolExists.c:
/* */
#include <pthread.h>
int main(int argc, char** argv)
{
(void)argv;
#ifndef pthread_create
return ((int*)(&pthread_create))[argc];
#else
(void)argc;
return 0;
#endif
}
Determining if the function pthread_create exists in the pthreads failed with the following output:
Change Dir: /home/humman/android-dev/cocos2d-x-3.5/cocos2d-x-3.5/build/linux-build/CMakeFiles/CMakeTmp
Run Build Command:"/usr/bin/gmake" "cmTryCompileExec3838281423/fast"
/usr/bin/gmake -f CMakeFiles/cmTryCompileExec3838281423.dir/build.make CMakeFiles/cmTryCompileExec3838281423.dir/build
gmake[1]: Entering directory '/home/humman/android-dev/cocos2d-x-3.5/cocos2d-x-3.5/build/linux-build/CMakeFiles/CMakeTmp'
/usr/bin/cmake -E cmake_progress_report /home/humman/android-dev/cocos2d-x-3.5/cocos2d-x-3.5/build/linux-build/CMakeFiles/CMakeTmp/CMakeFiles 1
Building C object CMakeFiles/cmTryCompileExec3838281423.dir/CheckFunctionExists.c.o
/usr/bin/cc -fno-exceptions -std=c99 -DCHECK_FUNCTION_EXISTS=pthread_create -o CMakeFiles/cmTryCompileExec3838281423.dir/CheckFunctionExists.c.o -c /usr/share/cmake/Modules/CheckFunctionExists.c
Linking C executable cmTryCompileExec3838281423
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTryCompileExec3838281423.dir/link.txt --verbose=1
/usr/bin/cc -fno-exceptions -std=c99 -DCHECK_FUNCTION_EXISTS=pthread_create CMakeFiles/cmTryCompileExec3838281423.dir/CheckFunctionExists.c.o -o cmTryCompileExec3838281423 -rdynamic -lpthreads
/usr/lib64/gcc/x86_64-suse-linux/4.8/../../../../x86_64-suse-linux/bin/ld: cannot find -lpthreads
collect2: error: ld returned 1 exit status
CMakeFiles/cmTryCompileExec3838281423.dir/build.make:88: recipe for target 'cmTryCompileExec3838281423' failed
gmake[1]: *** [cmTryCompileExec3838281423] Error 1
gmake[1]: Leaving directory '/home/humman/android-dev/cocos2d-x-3.5/cocos2d-x-3.5/build/linux-build/CMakeFiles/CMakeTmp'
Makefile:118: recipe for target 'cmTryCompileExec3838281423/fast' failed
gmake: *** [cmTryCompileExec3838281423/fast] Error 2
I installed the dependencies and libraries manually, but I still get this error. Does anyone know whats going on?
Note: when i try to compile, the first 2 lines are:
~/android-dev/cocos2d-x-3.5/cocos2d-x-3.5/build/linux-build> cmake ../..
CMake Error at CMakeLists.txt:35 (cmake_policy):
Policy "CMP0054" is not known to this version of CMake.
Thanks :D
Solved, I just did comment this lines out in the CMakeList.txt file
#if(CMAKE_VERSION VERSION_GREATER 3)
#cmake_policy(SET CMP0054 NEW)
#endif()
but now, when I use make command (No matter where, using NetBeans or terminal) it ends with this error at 98% (after about 15mins compiling)
[ 98%] Built target cocos2d
[ 98%] Built target MyGame_CORE_PRE_BUILD
MyGame_PRE_BUILD ...
[ 98%] Built target MyGame_PRE_BUILD
Linking CXX executable bin/MyGame
/usr/lib64/gcc/x86_64-suse-linux/4.8/../../../../x86_64-suse-linux/bin/ld: lib/libcocos2d.a(CCSpriteFrameCache.cpp.o): undefined reference to symbol '_ZSt28_Rb_tree_rebalance_for_erasePSt18_Rb_tree_node_baseRS_##GLIBCXX_3.4'
/usr/lib64/libstdc++.so.6: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
CMakeFiles/MyGame.dir/build.make:164: recipe for target 'bin/MyGame' failed
make[2]: *** [bin/MyGame] Error 1
CMakeFiles/Makefile2:64: recipe for target 'CMakeFiles/MyGame.dir/all' failed
make[1]: *** [CMakeFiles/MyGame.dir/all] Error 2
Makefile:76: recipe for target 'all' failed
make: *** [all] Error 2
Any idea??
Solved, If anyone has the same problem, just use cmake with the argument -pthread and then you will be able to build using make. If you wanna build using NetBeans, u have to leave only the -G "Unix..." argument and add in the CMakefile.txt the line: set(-pthread) --I did add it at the top-- and thats all, it should be everything ok :D cheers!
This appears to be a long-standing CMake bug. Something else is going wrong, CMake gets confused, and reports this spurious problem instead of the real error.
Look for "thread" in your CMakeLists.txt file and temporarily remove that.