I have the following files
main.cpp:
#include "f.h"
int main(){
f();
}
f.h:
int f();
f.cpp:
int f(){
int x=1;
}
First I am compiling f.cpp to an object file: gcc -c f.cpp -O0
and use this object file to compile main.cpp gcc f.o main.cpp.
Performing gdb a.out, info functions shows f(). Executing strip a.out removes it.
I would like to do the same thing using Cmake. I have created the following directory structure with main directories f and main:
f
build
src
f.h
f.c
CMakeLists.txt
CMakeLists.txt:
cmake_minimum_required(VERSION 2.8.8)
project(f)
set(CMAKE_BUILD_TYPE Release)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O0")
add_library(f OBJECT
f.cpp
)
main
build
src
main.cpp
CMakeLists.txt
CMakeLists.txt:
cmake_minimum_required(VERSION 2.8.8)
project(main)
set(CMAKE_BUILD_TYPE Release)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../../f/src
${CMAKE_CURRENT_SOURCE_DIR}/../../f/build)
add_executable(main
main.cpp
$<TARGET_OBJECTS:f>
)
I ran cmake and make first in f, after that in main. I have got the main executable with f(). However issuing strip main, or even strip -s main does not remove the symbolic name f().
- Why does not remove
stripthe symbolic names if I use Cmake? - Is there a way to compile my files in the same way (object file from f.cpp and after that main executable) using Cmake, and remove symbolic names from the executable?