Cmake/cpack: how to create a libc++ static library deb without headers? - cmake

I have been trying to create a deb for LLVM libc++ 3.4 on a Ubuntu 12.04LTS 64bit box tonight. I would like to first create a deb that just consists of just /usr/lib64/libc++.a without any headers. Yes, I know per Debian library packaging guide, I should include the file in a *-dev package, But being new to cmake and cpack, I would like to get there incrementally.
So, I first changed the libcxx-3.4/lib/CMakeLists.txt and added an if check (see line 14 and 18)
$ cat CMakeLists.txt
1 if (NOT LIBCXX_INSTALL_SUPPORT_HEADERS)
2 set(LIBCXX_SUPPORT_HEADER_PATTERN PATTERN "support" EXCLUDE)
3 endif()
4
5 file(COPY .
6 DESTINATION "${CMAKE_BINARY_DIR}/include/c++/v1"
7 FILES_MATCHING
8 PATTERN "*"
9 PATTERN "CMakeLists.txt" EXCLUDE
10 PATTERN ".svn" EXCLUDE
11 ${LIBCXX_SUPPORT_HEADER_PATTERN}
12 )
13
14 if (${LIBCXX_ENABLE_SHARED} MATCHES "ON")
15 install(DIRECTORY "${CMAKE_BINARY_DIR}/include/c++/v1/"
16 DESTINATION include/c++/v1/
17 )
18 endif()
Then, at in the build subdirectory, I issued a
CC=clang CXX=clang++ cmake -j2 -G "Unix Makefiles" -DLIBCXX_CXX_ABI=libcxxabi -DLIBCXX_LIBCXXABI_INCLUDE_PATHS="../libcxxabi/include" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr ../libcxx -DLIBCXX_ENABLE_SHARED=OFF
The created deb still consists of all headers. If I commented out lines 14 to 18, then no headers were included in the package. I am puzzled by this. A variable defined for the parent CMakeLists.txt should be picked up by a child CMakeLists.txt. What did I miss? I would appreciate a hint or two.

I have figured out the answer for my own question. Being new to cmake and cpack, I initially focused on the wrong CMakeLists.txt. The install command for headers in the include/CMakeLists.txt is not the only one. The main CMakeLists.txt file has a marcro in which there is also an install command. That should be disabled too. Specifically:
In the main CMakeLists.txt, one could do:
129 message(STATUS "Inside of setup_abi_libs; LIBCXX_ENABLE_SHARED: ${LIBCXX_ENABLE_SHARED}")
130 if (LIBCXX_ENABLE_SHARED)
131 install(DIRECTORY "${CMAKE_BINARY_DIR}/include/"
132 DESTINATION include/c++/v1
133 FILES_MATCHING
134 PATTERN "*"
135 )
136 endif()
137 endmacro()
Then, in the include/CMakeLists.txt, one could do:
13
14 message(STATUS "Inside of include; LIBCXX_ENABLE_SHARED: ${LIBCXX_ENABLE_SHARED}")
15
16 if (LIBCXX_ENABLE_SHARED)
17 install(DIRECTORY "${CMAKE_BINARY_DIR}/include/c++/v1/"
18 DESTINATION include/c++/v1/
19 )
20 endif()
This is the end result that I was trying to obtain but failed last night:
$ dpkg-deb -c libcxx_3.4-1_amd64.deb
drwxrwxr-x root/root 0 2014-03-04 08:59 ./usr/
drwxrwxr-x root/root 0 2014-03-04 08:59 ./usr/lib64/
-rw-r--r-- root/root 1928770 2014-03-04 08:58 ./usr/lib64/libc++.a
No more headers. Now I just need to figure out how to change the original CMakeLists.txt files to make a real dev package :)

Please read documenation for if:
MATCHES is for regular expressions, use if (LIBCXX_ENABLE_SHARED) or if (${LIBCXX_ENABLE_SHARED} STREQUAL "ON") instead

Related

cpack (creating RPM) ignores CMAKE_INSTALL_RPATH (sets RPATH to empty string - rather than an explicit value)

I'm trying a fairly simple experiment using cpack. The aim is to create an RPM installer (using cpack) with a trivial executable which uses an external 3rd party shared library (called libSomeSharedLib.so).
The structure I'd like the RPM to install is
opt
|_cmakeFindPackageTest
|_bin
|_cmakeFindPackageTest (an executable)
|_lib
|_libSomeSharedLib.so (the shared library)
I want the executable's RPATH to be /opt/cmakeFindPackageTest/lib (to ensure it uses the installed shared lib).
The full CMakeLists.txt is pasted at the bottom, but note the following properties are SET
15 SET(CMAKE_INSTALL_PREFIX "/opt/cmakeFindPackageTest")
16 SET( INSTALL_DIR_BIN ${CMAKE_INSTALL_PREFIX}/bin )
17 SET( INSTALL_DIR_LIB ${CMAKE_INSTALL_PREFIX}/lib )
18
19 SET(CMAKE_INSTALL_RPATH "\${INSTALL_DIR_LIB}")
20 SET(CMAKE_SKIP_BUILD_RPATH TRUE)
21 SET(CMAKE_SKIP_INSTALL_RPATH FALSE)
To my understanding, lines 17,19,20 should cause cpack to set the executable's RPATH to /opt/cmakeFindPackageTest/lib
HOWEVER...
when I build the project (from clean) and run cpack to generate an RPM I see this in the output
bash-4.2$ cpack -V -G RPM
CPack: Enable Verbose
... irrelevant looking output ommitted ...
CPack Verbose: Set runtime path of "/local/bfarnham/workspace/OPC-UA/CMake_examples/cmakeFindPackageTest/build/_CPack_Packages/Linux/RPM/cmakeFindPackageTest-0.0.0-Linux/opt/cmakeFindPackageTest/bin/cmakeFindPackageTest" to ""
RPATH gets set to empty! Eh? Checked with readelf - sure enough
bash-4.2$ readelf -d ./_CPack_Packages/Linux/RPM/cmakeFindPackageTest-0.0.0-Linux/opt/cmakeFindPackageTest/bin/cmakeFindPackageTest | grep --context=1 -i RPATH
0x0000000000000001 (NEEDED) Shared library: [libc.so.6]
0x000000000000000f (RPATH) Library rpath: []
0x000000000000000c (INIT) 0x400848
So, finally, the question: how do I get cpack to set the RPATH of this executable in the RPM ?
================ full CMakeLists.txt ================
1 cmake_minimum_required( VERSION 3.0 )
2 project( cmakeFindPackageTest CXX )
3 set (CMAKE_CXX_STANDARD 11)
4
5 list( INSERT CMAKE_MODULE_PATH 0 ${CMAKE_SOURCE_DIR}/cmake )
6 message( STATUS "CMAKE_MODULE_PATH [${CMAKE_MODULE_PATH}]" )
7 find_package( SomeSharedLib 1.0 REQUIRED MODULE )
8 message( STATUS "SomeSharedLib_INCLUDE_DIR [${SomeSharedLib_INCLUDE_DIR}] SomeSharedLib_LIBRARY [${SomeSharedLib_LIBRARY}]" )
9
10 add_executable( cmakeFindPackageTest src/main.cpp )
11 target_link_libraries( cmakeFindPackageTest SomeSharedLib::SomeSharedLib )
12
13 # =============================== INSTALL DETAILS BELOW THIS POINT ==========================
14
15 SET(CMAKE_INSTALL_PREFIX "/opt/cmakeFindPackageTest")
16 SET( INSTALL_DIR_BIN ${CMAKE_INSTALL_PREFIX}/bin )
17 SET( INSTALL_DIR_LIB ${CMAKE_INSTALL_PREFIX}/lib )
18
19 SET(CMAKE_INSTALL_RPATH "\${INSTALL_DIR_LIB}")
20 SET(CMAKE_SKIP_BUILD_RPATH TRUE)
21 SET(CMAKE_SKIP_INSTALL_RPATH FALSE)
22 SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH FALSE)
23
24 SET(CPACK_PACKAGE_NAME cmakeFindPackageTest )
25 SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "test")
26 SET(CPACK_PACKAGE_VENDOR "TEST_VENDOR")
27 SET(CPACK_PACKAGE_RELOCATABLE FALSE)
28 SET(CPACK_PACKAGE_VERSION_MAJOR "0")
29 SET(CPACK_PACKAGE_VERSION_MINOR "0")
30 SET(CPACK_PACKAGE_VERSION_PATCH "0")
31
32 install( TARGETS
33 cmakeFindPackageTest
34 RUNTIME DESTINATION ${INSTALL_DIR_BIN} )
35
36 install( FILES
37 ${SomeSharedLib_LIBRARY}
38 DESTINATION ${INSTALL_DIR_LIB} )
39
40 include( CPack )
I fixed this by explicitly setting the INSTALL_RPATH property value for the executable target. So, the addition of the set_target_properties line after the call to install
install( TARGETS
cmakeFindPackageTest
RUNTIME DESTINATION ${INSTALL_DIR_BIN} )
set_target_properties( cmakeFindPackageTest PROPERTIES INSTALL_RPATH "/opt/cmakeFindPackageTest/lib" )
From the cmake/cpack documentation it seemed like setting the CMAKE_INSTALL_RPATH variable should have worked. The CMAKE_INSTALL_RPATH docs read
The rpath to use for installed targets.
A semicolon-separated list specifying the rpath to use in installed
targets (for platforms that support it). This is used to initialize
the target property INSTALL_RPATH for all targets.
This is not an answer; rather an addendum to the fix described above...
With the fix above, cpack generates an RPM with an executable with the correct RPATH. However, the RPM was 'broken': installation fails - despite the RPM containing the required shared library, it appears cpackRPM somehow did not give it the corresponding attributes in the generated RPM. Install fails like this
bash-4.2$ sudo yum install cmakeFindPackageTest-0.0.0-Linux.rpm
Loaded plugins: changelog, fastestmirror, kernel-module, langpacks, protectbase, tsflags, versionlock
Examining cmakeFindPackageTest-0.0.0-Linux.rpm: cmakefindpackagetest-0.0.0-1.x86_64
Marking cmakeFindPackageTest-0.0.0-Linux.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package cmakefindpackagetest.x86_64 0:0.0.0-1 will be installed
--> Processing Dependency: libSomeSharedLib.so()(64bit) for package: cmakefindpackagetest-0.0.0-1.x86_64
Loading mirror speeds from cached hostfile
211 packages excluded due to repository protections
--> Finished Dependency Resolution
Beginning Kernel Module Plugin
Finished Kernel Module Plugin
Error: Package: cmakefindpackagetest-0.0.0-1.x86_64 (/cmakeFindPackageTest-0.0.0-Linux)
Requires: libSomeSharedLib.so()(64bit)
You could try using --skip-broken to work around the problem
You could try running: rpm -Va --nofiles --nodigest
bash-4.2$
This is resolved by instructing cpack to install the 3rd party library not as a FILE but as as PROGRAM. The key block of the CMakeLists.txt is
22 install( PROGRAMS
23 ${SomeSharedLib_LIBRARY}
24 DESTINATION ${INSTALL_DIR_LIB} )
The full CMakeLists.txt file is pasted below. This creates an RPM with executable RPATH set to the installation site lib directory, and the shared lib correctly identified as a shared library during RPM installation (i.e. resolves the 'Requires: libSomeSharedLib.so' failure)
1 cmake_minimum_required( VERSION 3.0 )
2 project( cmakeFindPackageTest CXX )
3 set (CMAKE_CXX_STANDARD 11)
4
5 list( INSERT CMAKE_MODULE_PATH 0 ${CMAKE_SOURCE_DIR}/cmake )
6 message( STATUS "CMAKE_MODULE_PATH [${CMAKE_MODULE_PATH}]" )
7 find_package( SomeSharedLib 1.0 REQUIRED MODULE )
8 message( STATUS "SomeSharedLib_INCLUDE_DIR [${SomeSharedLib_INCLUDE_DIR}] SomeSharedLib_LIBRARY [${SomeSharedLib_LIBRARY}]" )
9
10 add_executable( cmakeFindPackageTest src/main.cpp )
11 target_link_libraries( cmakeFindPackageTest SomeSharedLib::SomeSharedLib )
12
13 SET(CMAKE_INSTALL_PREFIX "/opt/cmakeFindPackageTest" )
14 SET(INSTALL_DIR_BIN ${CMAKE_INSTALL_PREFIX}/bin)
15 SET(INSTALL_DIR_LIB ${CMAKE_INSTALL_PREFIX}/lib)
16
17 install( TARGETS
18 cmakeFindPackageTest
19 RUNTIME DESTINATION ${INSTALL_DIR_BIN} )
20 set_target_properties( cmakeFindPackageTest PROPERTIES INSTALL_RPATH "${INSTALL_DIR_LIB}" )
21
22 install( PROGRAMS
23 ${SomeSharedLib_LIBRARY}
24 DESTINATION ${INSTALL_DIR_LIB} )
25
26 SET(CPACK_PACKAGE_NAME cmakeFindPackageTest )
27 SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "test")
28 SET(CPACK_PACKAGE_VENDOR "TEST_VENDOR")
29 SET(CPACK_PACKAGE_RELOCATABLE FALSE)
30 SET(CPACK_PACKAGE_VERSION_MAJOR "0")
31 SET(CPACK_PACKAGE_VERSION_MINOR "0")
32 SET(CPACK_PACKAGE_VERSION_PATCH "0")
33
34 include( CPack )
35 #include (${PROJECT_SOURCE_DIR}/CMakeEpilogue.cmake)

CMake INSTALL and RENAME cannot find file

I'm trying to make and install a config.cmake file for the project that I'm building, and the install part isn't working because apparently it can't find the file. I was originally using the INSTALL command from cmake, and when that didn't work I tried file( RENAME ... ) because I have a little more experience with it - neither seem to work. I've verified that the file is being made in the correct location and with the expected filename.
This is the relevant part of the CMakeLists.txt:
################################################################################
# Build the config.cmake file for finding project information
################################################################################
file(WRITE ${CMAKE_BINARY_DIR}/${PROJECT_NAME}Config.cmake "set(${PROJECT_NAME}_PROTO_DIR ${PROTO_MAIN_DIR})\n")
file(APPEND ${CMAKE_BINARY_DIR}/${PROJECT_NAME}Config.cmake "set(${PROJECT_NAME}_INCLUDE_DIR ${CMAKE_CURRENT_LIST_DIR}/include/;${PROTO_GEN_DIR})\n")
file(APPEND ${CMAKE_BINARY_DIR}/${PROJECT_NAME}Config.cmake "set(${PROJECT_NAME}_LIBRARY_DIR ${CMAKE_CURRENT_LIST_DIR}/lib/)\n")
file(APPEND ${CMAKE_BINARY_DIR}/${PROJECT_NAME}Config.cmake "set(${PROJECT_NAME}_LIBRARIES ${PROJECT_LIBRARIES})\n")
message( "CMAKE_BINARY_DIR: " ${CMAKE_BINARY_DIR} )
message( "PROJECT_NAME: " ${PROJECT_NAME} )
#INSTALL(FILES ${CMAKE_BINARY_DIR}/${PROJECT_NAME}Config.cmake DESTINATION ~/CMake/Modules/)
file(RENAME ${CMAKE_BINARY_DIR}/${PROJECT_NAME}Config.cmake ~/CMake/Modules/${PROJECT_NAME}Config.cmake)
Here's the relevant output when I try to rune cmake:
CMAKE_BINARY_DIR: /home/ava/workspace/frontseat_drivers/build
PROJECT_NAME: frontseat
CMake Error at src/frontseat/CMakeLists.txt:47 (file):
file RENAME failed to rename
/home/ava/workspace/frontseat_drivers/build/frontseatConfig.cmake
to
~/CMake/Modules/frontseatConfig.cmake
because: No such file or directory
and here's output confirming that the file is where I expect with the name that I expect:
ava#3b97b310abf0:~/workspace/frontseat_drivers/build$ ls -l
total 32
-rw-rw-r--. 1 ava ava 12219 Jun 13 19:04 CMakeCache.txt
drwxrwxr-x. 5 ava ava 4096 Jun 13 18:48 CMakeFiles
-rw-rw-r--. 1 ava ava 2250 Jun 13 15:41 cmake_install.cmake
-rw-rw-r--. 1 ava ava 315 Jun 14 12:30 frontseatConfig.cmake
-rw-rw-r--. 1 ava ava 6397 Jun 13 18:48 Makefile
drwxrwxr-x. 5 ava ava 98 Jun 13 18:48 src
What would cause CMake not to be able to see the file?
The error is probably about destination file ~/CMake/Modules/frontseatConfig.cmake. It is because CMake doesn't interpret ~ part, so it cannot resolve the path correctly.
Instead of ~ use $ENV{HOME} for point to the user's home directory.

CMake: Not to use /usr/lib64/libXmu.so

I am new to CMake and Geant4. I am trying to build a project using them.
Also, I am working in a remote cluster. When I cmake, there's no error. But when I do make the error I am getting is,
make[2]: *** No rule to make target '/usr/lib64/libXmu.so', needed by 'PRO_simulation'. Stop.
make[1]: *** [CMakeFiles/PRO_simulation.dir/all] Error 2
make: *** [all] Error 2
however,
ls -rt /usr/lib64/libXmu*
gives:
lrwxrwxrwx. 1 root root 15 Jan 11 2016 /usr/lib64/libXmu.so.6 -> libXmu.so.6.2.0
-rwxr-xr-x. 1 root root 109552 Nov 20 2015 /usr/lib64/libXmu.so.6.2.0
lrwxrwxrwx. 1 root root 16 Jan 11 2016 /usr/lib64/libXmuu.so.1 -> libXmuu.so.1.0.0
-rwxr-xr-x. 1 root root 19440 Nov 20 2015 /usr/lib64/libXmuu.so.1.0.0
Since its a remote cluster I cannot do a link with the name "libXmu.so" (After requesting the cluster authorities, still there's no use), but I can do the link to my local directory.
Now my question is what should I do in cmake such that, it will look for libXmu.so in my local directory instead of /usr/lib64/libXmu.so
First of all, this is a hack and by no means a proper solution, but you can link directly to a .so file: Link .so file to .cpp file via g++ compiling
Open CMakeLists.txt and remove all references to libXmu linking in target_link_libraries for all targets.
Add /home/user/path/to/libXmu.so to the cmake CXX or link flags. More information on how to do that can be found in: How do I add a linker or compile flag in a CMake file? or: Set CFLAGS and CXXFLAGS options using CMake
I would recommend that you first try something such as:
export CFLAGS=/home/user/path/to/libXmu.so
export CXXFLAGS=/home/user/path/to/libXmu.so
Before running cmake. If this fails, open CMakeLists.txt and try to find where extra CFLAGS and CXXFLAGS are defined and add the path to libXmu.so
Another thing that you can do is you can run make VERBOSE=1, which will show you the exact gcc/g++ command issued, copy it in a text editor and replace -lxmu with /home/user/path/to/libXmu.so
I hope at least one of those works.

CMake define new target by string processing existing $<TARGET_FILE>

I"m trying to modernize an older CMake script that essentially does the following to generate a libtool file:
get_target_property(target_location ${target} LOCATION)
get_filename_component(target_we ${target_location} NAME_WE)
get_target_property(target_deps ${target} LT_DEPENDENCY_LIBS)
# ...
# Get a bunch more properties...
# ...
set(la_target ${PROJECT_BINARY_DIR}/${target_we}.la)
# ...
# Do a bunch of file(WRITE...) file(APPEND...) etc
# ...
install(FILES ${la_target} DESTINATION ${CMAKE_INSTALL_PREFIX}/lib)
You cannot get the LOCATION property from a target in modern cmake, and I can't figure out how to do get_filename_component() on a $ generator.
Using the generator in an add_custom_command() COMMAND statement only allows one line, so I can't set variables to do all the necessary get_target_property()/file(WRITE...) processing.
Alternatively I can add a COMMAND cmake -P script.cmake to run a script which can do all the string processing but can't define or reference targets, so I appear to be stuck.
EDIT: I'm using the Makefile generator, on macOS, the target in question is a shared library that's generated in the same project.
EDIT2: The error is:
The LOCATION property may not be read from target "mytarget".
Use the target name directly with add_custom_command, or use
the generator expression $<TARGET_FILE>, as appropriate.
You can to it like this:
first use file command to expand generator expressions and render a level-2 template
... which is going to be rendered at build time by configure_file
Here is a sample project:
cmake_minimum_required(VERSION 3.10)
project(location-test VERSION 0.0.1 LANGUAGES CXX)
add_executable(foo foo.cc)
file(GENERATE OUTPUT blah.la.in INPUT blah.la.in.in)
configure_file(render-variables.cmake.in render-variables.cmake #ONLY)
add_custom_command(
OUTPUT "${PROJECT_BINARY_DIR}/blah.la"
COMMAND "${CMAKE_COMMAND}"
-DPROJECT_BINARY_DIR="${PROJECT_BINARY_DIR}"
-DPROJECT_NAME="${PROJECT_NAME}"
-DPROJECT_VERSION="${PROJECT_VERSION}"
-P "${PROJECT_BINARY_DIR}/render-variables.cmake"
MAIN_DEPENDENCY "${PROJECT_BINARY_DIR}/blah.la.in"
DEPENDS "${PROJECT_BINARY_DIR}/render-variables.cmake"
)
add_custom_target(
make-la-la-la ALL
DEPENDS "${PROJECT_BINARY_DIR}/blah.la"
)
blah.la.in.in (2-levels of tempaltes %):
# This file going to be rendered by the following pipeline:
# - at CMake execution time it'll expand all generator expressions
# (e.g. $<TARGET_FILE:foo>)
# - at build time, the `render-variables.cmake` script will substitute
# CMake variables (like #PROJECT_NAME# or #PROJECT_VERSION#)
write the template for your real .la file... render-variables.cmake.in is trivial as :
configure_file("${PROJECT_BINARY_DIR}/blah.la.in" "${PROJECT_BINARY_DIR}/blah.la" #ONLY)
And finally a dummy C++ file foo.cc:
#include <iostream>
int main()
{
std::cout << "Hello Africa!\n";
}
Build it!
localtion-sample$ mkdir build/
localtion-sample$ cd build/
localtion-sample/build$ cmake ..
-- The CXX compiler identification is GNU 5.4.0
-- Check for working CXX compiler: /usr/x86_64-pc-linux-gnu/gcc-bin/5.4.0/c++ -- works
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: /tmp/localtion-sample/build
localtion-sample/build$ make
Scanning dependencies of target foo
[ 33%] Building CXX object CMakeFiles/foo.dir/foo.cc.o
[ 66%] Linking CXX executable foo
[ 66%] Built target foo
Scanning dependencies of target make-la-la-la
[100%] Generating blah.la
[100%] Built target make-la-la-la
localtion-sample/build$ ll
total 52K
drwxr-xr-x 6 zaufi zaufi 320 Feb 9 22:35 CMakeFiles/
-rw-r--r-- 1 zaufi zaufi 287 Feb 9 22:35 blah.la
-rw-r--r-- 1 zaufi zaufi 300 Feb 9 22:35 blah.la.in
-rw-r--r-- 1 zaufi zaufi 11K Feb 9 22:35 CMakeCache.txt
-rw-r--r-- 1 zaufi zaufi 1.5K Feb 9 22:35 cmake_install.cmake
-rwxr-xr-x 1 zaufi zaufi 14K Feb 9 22:35 foo
-rw-r--r-- 1 zaufi zaufi 5.0K Feb 9 22:35 Makefile
-rw-r--r-- 1 zaufi zaufi 89 Feb 9 22:35 render-variables.cmake
localtion-sample/build$ cat blah.la
# This file going to be rendered by the following pipeline:
# - at CMake execution time it'll expand all generator expressions
# (e.g. /tmp/localtion-sample/build/foo)
# - at build time, the `render-variables.cmake` script will substitute
# CMake variables (like location-test or 0.0.1)

embedding mono sample: error while loading shared libraries: libmonoboehm-2.0.so.1

i've installed mono on centos 6 via make && make install from source
when i tried this sample:
https://github.com/mono/mono/blob/master/samples/embed/teste.c
no error occured during the compilation, but when i run i got this:
[root#WOH_Test t01]# gcc -o teste teste.c `pkg-config --cflags --libs mono-2` -lm
[root#WOH_Test t01]# mcs test.cs
[root#WOH_Test t01]# ./teste test.exe
./teste: error while loading shared libraries: libmonoboehm-2.0.so.1: cannot open shared object file: No such file or directory
i can't figure where the problem is, any clue?
What do you have in /usr/local/lib? If you didn't use the --prefix option while running autogen.sh before the command make the libraries should be localed in /usr/local/lib. You should see in that directory something like this:
me#mypc:/usr/local/lib$ ls -lah libmono-2.0.*
lrwxrwxrwx. 1 me me 18 dic 19 00:38 libmono-2.0.a -> libmonoboehm-2.0.a
lrwxrwxrwx. 1 me me 19 dic 19 00:38 libmono-2.0.la -> libmonoboehm-2.0.la
lrwxrwxrwx. 1 me me 19 dic 19 00:38 libmono-2.0.so -> libmonoboehm-2.0.so
lrwxrwxrwx. 1 me me 21 dic 19 00:38 libmono-2.0.so.1 -> libmonoboehm-2.0.so.1
lrwxrwxrwx. 1 me me 25 dic 19 00:38 libmono-2.0.so.1.0.0 -> libmonoboehm-2.0.so.1.0.0
If you can see the above libraries in /usr/local/lib your problem is related to where is ld searching for libraries. From this question: CentOS /usr/local/lib system wide $LD_LIBRARY_PATH I guess Centos6 does not have by default configuration for /usr/local/lib. If it is your case, just use the provided solutions in that question (any of them) and your program should work fine.
EDIT
From your comment if you want libmonoboehm-2.0.so.1 in the same path as the teste program and you do not want to touch anything else in your Centos6 you could do something like the following:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/path/to/teste/binary
./teste test.exe
But I wonder what output do you have when you run this command: pkg-config --cflags --libs mono-2 (it seems as if you already had a mono installation in your Centos6)
Anyhow, if you can modify your Centos6 the best is this answer: CentOS /usr/local/lib system wide $LD_LIBRARY_PATH. You do that once and you will be able to run any mono program without having to mess with the LD_LIBRARY_PATH environment variable. In your case you should do the following:
1. Edit /etc/ld.so.conf
2. Write this: /opt/mono/lib
3. Run ldconfig -v as root
4. Your Centos6 is ready to run your mono programs whenever you wish (even if you restart your Centos6 machine)
END EDIT