Implementation Strategy for C ++ Executable

I recently asked a question about what I should use to create standalone executables that will be deployed across a number of Linux distributions . At first I was very scared, but after reading a little about C ++, I managed to get the first version of my executable file.

After a day of joy, I hit the wall again with another dilemma. The resulting executable file must be installed on a number of Linux distributions (Slackware, Arch, Ubuntu, Debian, CentOS, and several more), and I absolutely do not know how to achieve it. Everything I know based on CentOS and Debian has package managers like apt or yum, but I'm not sure if they apply to my case.

The code I wrote depends on several libraries (more specifically, RudeSocket and yaml-cpp I was told that I could compile the executable and link it dynamically, so I just needed to distribute the executable.

It happens that I could not find the .a file for the yaml-cpp library (only for RudeSocket). And here is my problem so far:

At first I went with dynamic link, but (obviously) when I copied the executable to another field:

$ ./main
./main: error while loading shared libraries: libyaml-cpp.so.0.2: cannot open shared object file: No such file or directory

When I try to compile it statically, I also get an error (because I don't have the yaml-cpp.a file, as I mentioned):

$ g++ main.cpp parse.cpp parse.h rudesocket-1.3.0/.libs/librudesocket.a -o main -static -L/usr/local/librudesocket-1.3.0/.libs/librudesocket.a(socket_connect_normal.o): In function `rude::sckt::Socket_Connect_Normal::simpleConnect(int&, char const*, int)':
/root/webbyget/sockets/rudesocket-1.3.0/src/socket_connect_normal.cpp:250: warning: Using 'gethostbyname' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/tmp/cc3cEVK1.o: In function `operator>>(YAML::Node const&, Job&)':
parse.cpp:(.text+0x1a83): undefined reference to `YAML::Node::size() const'
/tmp/cc3cEVK1.o: In function `handle_job(rude::Socket, char const*)':
parse.cpp:(.text+0x1b79): undefined reference to `YAML::Parser::Parser(std::basic_istream<char, std::char_traits<char> >&)'
parse.cpp:(.text+0x1bfd): undefined reference to `YAML::Node::Node()'
parse.cpp:(.text+0x1c10): undefined reference to `YAML::Parser::GetNextDocument(YAML::Node&)'
parse.cpp:(.text+0x1dc6): undefined reference to `YAML::Node::size() const'
parse.cpp:(.text+0x1dee): undefined reference to `YAML::Node::~Node()'
parse.cpp:(.text+0x1e18): undefined reference to `YAML::Node::~Node()'
parse.cpp:(.text+0x1e37): undefined reference to `YAML::Parser::~Parser()'
parse.cpp:(.text+0x1e61): undefined reference to `YAML::Parser::~Parser()'
(...)

It is pretty obvious to me that g ++ cannot compile it statically without telling him where to find the classes for yaml-cpp.

It is very important that the installation is carried out without human interaction in an automatic way.

, :

  • , ?

  • - - ?

,

.

+3
4

.

+4

-, .:( , , , , . rpm deb, , 90% . , autoconf/automake () .

0

(.rpm .deb), , .

CPack, ,

0

, CMake.

CMake is an open source cross-platform system. This is a family of tools for building, testing, and bundled software. To pack Mgb rights, CMake can be easily linked to CPack .

KDE uses this solution and is a very good alternative to automake / autoconf.

0
source

Source: https://habr.com/ru/post/1717589/


All Articles