Compiling an existing C++ program using Makefile - c++

Edit: not solved, but as I moved on to other software, I ran into other challenges.
For a research project, I downloaded a Github project (Tagliasacchi et al., 2015) for computer vision to Linux 16.04. I have programming experience with PHP but I am new to C++. When I try to replicate the results of the study on my computer, I run early into a compiling error.
The Hello world-example of the Github project (apps » helloworld) works fine.
When trying to compile another application, I run into an error with the Makefile: cmake . works fine and some files are created. However, make does not work.
After the error, g++ [filename].cpp -o main obviously does not work.
How to solve this and get the dependencies right?
In some cases, there is a Makefile, but I run into an error:
[ 33%] Building CXX object CMakeFiles/helloworld_atb.dir/main.cpp.o
/bin/sh: 1: /usr/bin/g++-4.8: not found
CMakeFiles/helloworld_atb.dir/build.make:62: recipe for target 'CMakeFiles/helloworld_atb.dir/main.cpp.o' failed
make[2]: *** [CMakeFiles/helloworld_atb.dir/main.cpp.o] Error 127
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/helloworld_atb.dir/all' failed
make[1]: *** [CMakeFiles/helloworld_atb.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
In other cases (e.g. in tracker » HandFinder), I can't run either cmake . or make and compiling using g++ HandFinder.cpp -o handfinder does not work:
In file included from HandFinder.cpp:1:0:
HandFinder.h:2:41: fatal error: tracker/ForwardDeclarations.h: No such file or directory
compilation terminated.

Related

certain headers arent being found, even though I've included them. Aside from using quotes, how can I fix this?

Ive downloaded the SDL2 library using brew install SDL2 but when I am trying to compile melonDS for Mac, I keep banging my head against the wall of the annoying error of
bash-3.2$ make
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/bigman/melonDS/build
[ 1%] Building CXX object CMakeFiles/melonDS.dir/src/libui_sdl/main.cpp.o
/Users/bigman/melonDS/src/libui_sdl/main.cpp:24:10: fatal error:
'SDL2/SDL.h' file not found
#include <SDL2/SDL.h>
^~~~~~~~~~~~
1 error generated.
make[2]: *** [CMakeFiles/melonDS.dir/src/libui_sdl/main.cpp.o] Error 1
make[1]: *** [CMakeFiles/melonDS.dir/all] Error 2
make: *** [all] Error 2
bash-3.2$
I've uninstalled, reinstalled, tried to use compiler flags in the makefile (which did't work because the project uses cmake) but to no avail. Any other reccomendations would be great.

CGREEN compilation error: ‘assertion_tests’ does not name a type

When I try to compile cgreen unit testing framework in cygwin64 I get this error:
[ 34%] Building CXX object tests/CMakeFiles/cgreen_cpp_tests.dir/assertion_tests.cpp.o
/home/Administrator/cgreen/tests/assertion_tests.cpp:1:1: error: ‘assertion_tests’ does not name a type
assertion_tests.c
^~~~~~~~~~~~~~~
make[2]: *** [tests/CMakeFiles/cgreen_cpp_tests.dir/build.make:63: tests/CMakeFiles/cgreen_cpp_tests.dir/assertion_tests.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:1615: tests/CMakeFiles/cgreen_cpp_tests.dir/all] Error 2 make: *** [Makefile:161: all] Error 2
I have searched on google with no result.
I am using cygwin64 with cmake 3.6.2 and gcc 7.3.0
Any help will be appreciated!
The assertion_tests.cpp file is a symlink, see github cgreen repo. Sadly, on windows symlink is converted into textfile with the path to the file it should link to. You need to convert the file into actual link, as well all the others links in the cgreen repo, and there are some. Some help on how to do it may be better found on this thread.

Error when compiling OpenCV for Qt

In order to use OpenCV in Qt, I have to compile it with MinGW by cmake.
Software are the following:
Qt 5.4.0
Opencv 2.4.11
CMake 3.2.2
MinGW version unknown, GCC 4.8.1
A fatal error occurred when I make file and I have no idea how to solve it at all.
[ 29%] Automatic moc for target opencv_highgui
Generating moc_window_QT.cpp
Exit code 0xc000007b
AUTOGEN: error: process for C:/opencvbuild/modules/highgui/moc_window_QT.cpp failed:
Exit code 0xc000007b
moc failed...
modules\highgui\CMakeFiles\opencv_highgui_automoc.dir\build.make:48: recipe for target 'modules/highgui/CMakeFiles/opencv_highgui_automoc' failed
mingw32-make[2]: *** [modules/highgui/CMakeFiles/opencv_highgui_automoc] Error 1
CMakeFiles\Makefile2:2066: recipe for target 'modules/highgui/CMakeFiles/opencv_highgui_automoc.dir/all' failed
mingw32-make[1]: *** [modules/highgui/CMakeFiles/opencv_highgui_automoc.dir/all] Error 2
Makefile:145: recipe for target 'all' failed
mingw32-make: *** [all] Error 2
These messages are shown in cmd.
Then I revised CMakeLists.txt, SET(CMAKE_AUTOMOC OFF)
modules\highgui\CMakeFiles\opencv_highgui_automoc.dir\build.make:64: recipe for target 'modules/highgui/qrc_window_QT.cpp' failed
Does anybody know a solution?
2 items to try.
Try running make with VERBOSE=1 to increase the output on the makefile. That should give you a better idea of what is wrong.
Try running with cmake-gui, then turn on advanced mode to check out what CMake found for the different Qt5 dependencies. On Mac, I install the latest Qt to my home directory, causing me to have to manually set variables. This is what it looks like for me.
Hopefully this provides some useful information.

llvm error: linking error to libLTO.so

During compilation of llvm I get following error:
llvm[2]: ======= Finished Linking Debug+Asserts Executable llvm-config
llvm[2]: Installing Debug+Asserts /usr/local/bin/llvm-config
make[2]: Leaving directory `/usr/bin/tools/llvm-config'
make[2]: Entering directory `/usr/bin/tools/lto'
llvm[2]: Compiling LTODisassembler.cpp for Debug+Asserts build (PIC)
llvm[2]: Compiling lto.cpp for Debug+Asserts build (PIC)
llvm[2]: Linking Debug+Asserts Shared Library libLTO.so
collect2: ld terminated with signal 9 [Killed]
make[2]: *** [/usr/bin/Debug+Asserts/lib/libLTO.so] Error 1
make[2]: Leaving directory `/usr/bin/tools/lto'
make[1]: *** [install] Error 1
make[1]: Leaving directory `/usr/bin/tools'
make: *** [install] Error 1
I do configure llvm by giving path of gcc & g++ compilers.
I don't get any error during configuration; but during build same error persist with clang also. I am using Ubntu-12.10 32 bit.
OK, so to solve this problem, I referred to llvm.org and during configuration added few options as follows:
sudo ./configure CC="/usr/bin/gcc" CXX="/usr/bin/g++" --enable-optimization --enable-jit --enable-debug-runtime --enable-targets=all
And I ran a build as SuperUser.
I faced the same error using Ubuntu 13.04 (arch: x86_64). The following error
collect2: ld terminated with signal 9 [Killed]
was an issue with memory usage. I was indeed using a Koding.com cloud VM with 1GB RAM.
I tried the compilation on my laptop as a normal user and the compilation finished without any issues. I used:
$ ./configure
$ make -j4

Installing Apache Kudu on WSL

I am trying to install Apache Kudu and run the C++ examples on my Ubuntu distribution (18.04) on WSL. I am following the instructions for Ubuntu at https://kudu.apache.org/docs/installation.html
Everything runs smoothly until I get to step 6 where I run
make -j4
I get the following errors
Exception in thread "main" java.util.zip.ZipException: error in opening zip file
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.<init>(ZipFile.java:225)
at java.util.zip.ZipFile.<init>(ZipFile.java:155)
at java.util.zip.ZipFile.<init>(ZipFile.java:169)
at org.gradle.wrapper.Install.unzip(Install.java:235)
at org.gradle.wrapper.Install.access$900(Install.java:27)
at org.gradle.wrapper.Install$1.call(Install.java:81)
at org.gradle.wrapper.Install$1.call(Install.java:48)
at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAccessManager.java:69)
at org.gradle.wrapper.Install.createDist(Install.java:48)
at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:107)
at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:63)
CMakeFiles/init_gradle.dir/build.make:60: recipe for target '../../java/gradle/wrapper/gradle-wrapper.jar' failed
make[2]: *** [../../java/gradle/wrapper/gradle-wrapper.jar] Error 1
make[2]: *** Deleting file '../../java/gradle/wrapper/gradle-wrapper.jar'
CMakeFiles/Makefile2:1708: recipe for target 'CMakeFiles/init_gradle.dir/all' failed
make[1]: *** [CMakeFiles/init_gradle.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[ 5%] Built target kudu_util_pb_util_proto
[ 5%] Built target kudu_util_hash_proto
[ 6%] Built target hms_thrift
Makefile:140: recipe for target 'all' failed
make: *** [all] Error 2
Image of error
Does anybody know what is causing the errors?
Happened to met same situation.
This exception is happened when building hms. And you can found verbose log by doing
cd <root_of_kudu>/java
./gradlew assemble
The problems I met is the zip of downloaded gradle seems wrong, so I cleaned ~/.gradle/wrapper/dists/gradle-6.2.2-all/2k4hz1yffuhb6ob9prdg10tx/gradle-6.2.2-all.zip and <root_of_kudu>/java/gradle/wrapper/gradle-wrapper.jar. And try to call make -j4 again.
Further more, if you happened to have same bad network like mine, you can download the gradle zip manually, by checking the content of <root_of_kudu>/java/gradlew, the line with curl tells you the download link, try to download it with a good network or a proxy and then place it to the first path you cleaned, it may work.