Compiling clang-llvm examples - c++

I am trying to compile the Hello example in directory lib/Transforms/Hello, which is basically a Hello World of LLVM pass, but I get the following error when I try to compile it using make.
../../../Makefile.common:61: ../../../Makefile.config: No such file or directory
../../../Makefile.common:69: /Makefile.rules: No such file or directory
make: *** No rule to make target `/Makefile.rules'. Stop.
Any idea what is the problem and how to fix it?

If you built LLVM + Clang according to instructions, the Hello sample should have already been built. Go to lib/Transforms/Hello in the build directory (where you ran configure and then make). There should be a Debug+Asserts (or whatever configuration you compiled) there. And you can also run make from there again.
In general, you always make from the build directory, not the source directory. The build directory has all the Makefiles properly set up.

Related

Can someone expand what is meant by 'configure' and 'build' with CMake files

I am downloading this code from GitHub (subdivision-regression), and am getting stuck following the instructions:
To build doosabin_regression:
Run CMake with an out of source build.
Set COMMON_CPP_INCLUDE_DIR to the full path to rstebbing/common/cpp.
Set DOOSABIN_INCLUDE_DIR to the full path to rstebbing/subdivision/cpp/doosabin/include.
Set Ceres_DIR to the directory containing CeresConfig.cmake.
Set GFLAGS_INCLUDE_DIR, GFLAGS_LIBRARY and RAPID_JSON_INCLUDE_DIR. (Add -std=c++11 to CMAKE_CXX_FLAGS if compiling with gcc.)
Configure.
Build.
I have edited the CMakeLists.txt file to put the correct paths in. I then created a new directory called subdivision-regression-bin and ran:
cmake ../subdivision-regression/src
It completes this and displays:
-- Configuring done
-- Generating done
-- Build files have been written to: /home/hert5584/RStebbing/subdivision-regression-bin
However, when I try and run the example code, it cannot find the files listed in CMakeLists.txt (I know they are the right paths as otherwise CMake does not run).
I have tried running:
sudo make install
But get the following error:
make: *** No rule to make target 'install'. Stop.
Any ideas why this isn't working? Have the above steps Configured and Built the files?
The ordered CMake idiom to understand is:
The Configure step
The Generate step (This is often subsumed in the Configure step, and not mentioned explicitly, as in this case.)
The Build step (in which you actually compile/link your code into libraries/executables)
Take a look at this resource for information about the configure and generate stages.
You didn't appear to perform the steps to set CMake cache variables. For these you have to use CMake command line options (-D specifically). So run CMake as something like this instead to set all six variables:
cmake -DCOMMON_CPP_INCLUDE_DIR=/rstebbing/common/cp -DDOOSABIN_INCLUDE_DIR=...[More CMake Cache variables]... ../subdivision-regression/src
For building, try just running make without sudo or install:
make

"make" error when building nana for c++

I've been trying to install the nana library for c++. I've used these guides:
https://github.com/qPCR4vir/nana-docs/wiki/Installation
https://github.com/qPCR4vir/nana-docs/wiki/Install-and-use-nana-with-mingw---step-by-step
I got stuck on the part that says "Create a static linkage library solution within a IDE/build system you use, and add all the files which are placed in NanaPath/source and in all its sub directories to the project. Then compile the solution and you will get a static linkage file NanaStatic in a path similar to NanaPath/build/bin/IDEName."
I downloaded MinGW, git, and cmake like it said. I opened up the bat file, ran the "git clone" with the link, ran
cmake -G "MinGW Makefiles"
It did it's thing and finished successfully. Then I tried running "make" and it got to 6% when this showed up:
In file included from C:/Users/.../nana/verbose_prepocessor.hpp:99:0,
from C:\Users\...\nana\source\deploy.cpp:242:C/Users/.../nana/include/filesystem/filesystem.hpp:71:39: fatal error: experimental/filesystem: No such file or directory
# include<experimental/filesystem>
^
compilation terminated.
make[2]: *** [CMakeFiles\nana.dir\build.make:163: CMakeFiles/nana.dir/source/deploy.cpp.obj] Error 1
make[1]: *** [CMakeFiles\Makefile2:67: CMakeFiles/nana.dir/all] Error 2
make: *** [Makefile:129: all] Error 2
I tried using a different source of the code (git and sourceforge) and that didn't make a difference. I tried using the GUI cmake, but I had other errors with that not recognizing MinGW. I looked around for answers online, but they mostly led back to the guides I was using. I checked my GCC and G++ version with gcc/g++ --version, and they're both 6.3.0.
I'll take any suggestions/advice, thanks!
I have not used Eclipse, so I cant help with that. But I will try to help with nana:
Originaly there was no std::filesystem and nana offered one JinHao invented. With the apparition of std::experimental::filsystem candidate, an experimental filesystem in the sdt:: c++ library of some versions of some compilers we adapted the nana filesystem to be a partial implementation of that. Then nana try to configure itself to use the provided std:: (or Boost) implementation or if it is not there then nana::filesystem. It seems like MinGW have problems with filesystem, I'm not sure about that but here you can read: https://github.com/Alexpux/MINGW-packages/issues/2292
Please try to undertstand what is going on in your case an let us know about. We will then try to fix the configuration of nana to work even in that situation.
You can always simply choise to (force) use the nana implementation. Just please compile both the nana library and your project with all the same options, including what filesytem you use. For example adding -DNANA_CMAKE_NANA_FILESYSTEM_FORCE=True to your cmake or define NANA_FILESYSTEM_FORCE in your built system (or IDE).

CMake : Executable crashes when running ctest

I am configuring CMake build project on Windows for MSVC++ project.It build ok the executable,then installs it into a defined directory.In my cases that's:
${CMAKE_SOURCE_DIR}/x64/${CMAKE_BUILD_TYPE}/
The executable has got a folder in the same directory with files which it loads upon the launch.If I launch the .exe manually it opens up and runs ok.But I want to do it via ctest.
I defined ctest like this:
add_test(ENGINE_TEST1 ${CMAKE_SOURCE_DIR}/x64/${CMAKE_BUILD_TYPE}/MyApp.exe
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/x64/${CMAKE_BUILD_TYPE})
When I call from the cmd:
ctest
The executable is starting up but crashes immediately with the error:
Debug Error!
Program:../..../.../MyApp.exe
R6010 -abort() has
been called.
Indeed,when checking the CMake's Last Test.log file it shows that it runs the test not in "WORKING_DIRECTORY but in the directory where the MyApp.exe has been built by CMake.How do I change that?
As I am not CMake pro I am sure the following answer is not the optimal way to do it,but at least it works for me.
Again,I was trying to run ctest on an executable from within the directory into which cmake had installed it.The exe on the startup was trying to load dependent files which were in the same directory.But it was crashing because it couldn't fin the files.
It appears that the cmake default workspace directory is the directory where the cmake files and projects are generated.That's 'build' directory.So when the executable is launched via ctest it search the paths of the files to load relative to the build directory.
Now,CMAKE has 2 variations of add_test() method.One is simple with arguments:
add_test([test_name] [test exe path])
It doesn't take care of the working directory.
And another one which is explained here does include an argument for explicit setup of the working directory.
Frankly speaking,I wasn't able to get this advanced function working as it was demanding to supply some test .config which I didn't understand how to setup.So what I did,I used the simple add_test function.
And then I set the working directory to the location of my executable using this:
set_tests_properties(mytest PROPERTIES WORKING_DIRECTORY "${TEST_WOKRING_DIR}")
And it fixed the problem.

how to generate glut .so file in Linux

I would like to generate glut .so file in Ubuntu. I've downloaded the files, extracted them and opened the readme. This is the instructions for Linux
MAKEFILE GENERATION TO BUILD GLUT: <-- IMPORTANT!
Use "mkmkfiles.sgi" to put Makefiles using the SGI Makefile conventions
in place. Use "mkmkfiles.imake" to put Makefiles generated from
Imakefiles in place. Run one of these two commands in this directory,
then do a "make".
I don't really understand SGI Makefile. I know Makefile though. Could you please guide me for generating the dll. In the folder, these are the files
adainclude Imakefile mkmkfiles.imake README.fortran README.man
CHANGES include mkmkfiles.sgi README.glut2 README.mesa
FAQ.glut lib mkmkfiles.win README.glut3 README.mui
Glut.cf linux NOTICE README.ibm-shlib README.win
glutdefs Makefile Portability.txt README.inventor README.xinput
glutmake.bat Makefile.sgi progs README.irix6 test
glutwin32.mak Makefile.win README README.irix64bit
IAFA-PACKAGE man README.ada README.linux
I've tried running make but getting errors and there is no CMakeLists. Thank you.
When I run ./mkmkfiles.sgi or mkmkfiles.imake, I get this error
bash: ./mkmkfiles.sgi: /bin/csh: bad interpreter: No such file or directory
Technically you need first to instal tcsh. With that installed, running mkmkfiles.imake will work and generate the required Makefile so you can build on Linux. Here is an old post asking pretty much the same question: http://comments.gmane.org/gmane.linux.lfs.general/17539

I can't run a program that uses allegro5 with cmake

EDIT: If you want to look at the code, here it is:
https://github.com/WalterCapa/PercolationCpp/tree/master
I'm making a program that uses allegro5 library to generate an animation.
Because i want to avoid the installation of the library on every computer that uses the program, i tried to paste the headers and the .so files in my project dir. So the tree is like this:
root
include
allegro5 <- (Dir where the headers of allegro are)
Percolation.h
QuickUnion.h
lib
allegro5 <-(Dir where the .so files are)
Percolation.cpp
QuickUnion.cpp
PercolationVisualizer <- (Dir that has the main)
The problem is this. I installed allegro5 in my pc with LinuxMint 13. Everything is fine if I compile from Code::Blocks or if I do it from the terminal using -I to call the hedaers and -L to tell where the .so files are, and even using cmake works fine, but when i try to do it in another computer, even if it's windows like my laptop or a virtual machine with linuxmint, it generates this error:
make[2]: *** No rule to make target '/./lib/allegro5/liballegro.so/', needed by'
../bin/PercolationVisualizer'. Stop.
make[1]: *** [CMakeFiles/PercolationVisualizer.dir/all] Error 2
make: *** [all] Error 2
This is my CMakeLists.txt:
cmake_minimum_required(VERSION 2.8.7)
project(PercolationCpp)
set(PercolationCpp_VERSION_MAJOR 0)
set(PercolationCpp_VERSION_MINOR 1)
set(EXECUTABLE_OUTPUT_PATH ../bin/)
set(percolation_SRCS PercolationVisualizer/PercolationVisualizer.cpp lib/Percolation.cpp lib/QuickUnion.cpp)
#Executable
add_executable(PercolationVisualizer ${percolation_SRCS})
#include Allegro
include_directories(./include)
link_directories(./lib/allegro5)
#connect all the libraries
set(allegro5_LIBS /./lib/allegro5/liballegro.so /./lib/allegro5/liballegro_primitives.so)
target_link_libraries(PercolationVisualizer ${allegro5_LIBS})
Btw, when trying it on windows with MinGW i used cmake -G "MinGW Makefiles" .. and mingw32-make.
It found the compiler and and cmake worked, but when i tried de second one it gave me the same error. In my desktop i'm compiling using g++.
I think that your actual problem is the leading / in this line:
set(allegro5_LIBS /./lib/allegro5/liballegro.so /./lib/allegro5/liballegro_primitives.so)
A leading slash will tell cmake to look for an absolute path (like /usr/lib...) and not prefix it with a CMAKE_*_DIR. Try this
set(allegro5_LIBS ${CMAKE_SOURCE_DIR}/lib/allegro5/liballegro.so ${CMAKE_SOURCE_DIR}/lib/allegro5/liballegro_primitives.so)
However I strong discourage you to include pre-built libraries in your project. If you can, integrate a tar-ball or a git-submodule. If the project you include is a cmake project itself, a simple call to add_subdirectory will make the targets (libraries usually) available to your project and create a dependency. If the project is based on configure you can use the ExternalProject-extension.