Panel użytkownika
Nazwa użytkownika:
Hasło:
Nie masz jeszcze konta?

CMake - zewnętrzna biblioteka pqxx

Ostatnio zmodyfikowano 2019-10-13 08:01
Autor Wiadomość
nicraM
Temat założony przez niniejszego użytkownika
CMake - zewnętrzna biblioteka pqxx
» 2019-10-10 16:40:30
Witam
W ramach nauki męczę się z ustawieniem zewnętrznej biblioteki dla postgresa. Chcę, aby mój projekt nie wymagał żadnych dodatkowych bibliotek, które trzeba instalować w systemie. Chcę wszystkie biblioteki mieć właśnie w projekcie.
Zaciągnąłem bibliotekę pqxx z gita jako submodule https://github.com/jtv/libpqxx git submodule add https://github.com/jtv/libpqxx.git lib/libpqxx

Teraz w CMakeLists.txt dodałem subdirectory i target

C/C++
add_subdirectory( lib / libpqxx )

include_directories( include lib / libpqxx / include )

target_link_libraries( sandbox pistache pthread pqxx )

Próbowałem używać add_library() find_package() ale nie chce mi się to budować :(

w pliku userService.h załączam nagłówek
#include "pqxx/pqxx"
 w kompilator wywala na tym error:

====================[ Build | sandbox | Debug ]=================================
/home/marcin/Programs/CLion/bin/cmake/linux/bin/cmake --build /home/marcin/CLionProjects/sandbox/cmake-build-debug --target sandbox -- -j 8
[ 62%] Built target pistache
[ 68%] Building CXX object CMakeFiles/sandbox.dir/src/Endpoint/userEndpoint.cpp.o
[ 75%] Building CXX object CMakeFiles/sandbox.dir/src/Helper/passwordEncoder.cpp.o
[ 75%] Building CXX object CMakeFiles/sandbox.dir/src/Service/userService.cpp.o
In file included from /home/marcin/CLionProjects/sandbox/lib/libpqxx/include/pqxx/array.hxx:14,
                 from /home/marcin/CLionProjects/sandbox/lib/libpqxx/include/pqxx/array:4,
                 from /home/marcin/CLionProjects/sandbox/lib/libpqxx/include/pqxx/pqxx:2,
                 from /home/marcin/CLionProjects/sandbox/include/userService.h:7,
                 from /home/marcin/CLionProjects/sandbox/src/Endpoint/userEndpoint.cpp:5:
/home/marcin/CLionProjects/sandbox/lib/libpqxx/include/pqxx/compiler-public.hxx:13:10: fatal error: pqxx/config-public-compiler.h: Nie ma takiego pliku ani katalogu
 #include "pqxx/config-public-compiler.h"
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
make[3]: *** [CMakeFiles/sandbox.dir/build.make:141: CMakeFiles/sandbox.dir/src/Endpoint/userEndpoint.cpp.o] Błąd 1
make[3]: *** Oczekiwanie na niezakończone zadania....
In file included from /home/marcin/CLionProjects/sandbox/lib/libpqxx/include/pqxx/array.hxx:14,
                 from /home/marcin/CLionProjects/sandbox/lib/libpqxx/include/pqxx/array:4,
                 from /home/marcin/CLionProjects/sandbox/lib/libpqxx/include/pqxx/pqxx:2,
                 from /home/marcin/CLionProjects/sandbox/include/userService.h:7,
                 from /home/marcin/CLionProjects/sandbox/src/Service/userService.cpp:8:
/home/marcin/CLionProjects/sandbox/lib/libpqxx/include/pqxx/compiler-public.hxx:13:10: fatal error: pqxx/config-public-compiler.h: Nie ma takiego pliku ani katalogu
 #include "pqxx/config-public-compiler.h"
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
make[3]: *** [CMakeFiles/sandbox.dir/build.make:180: CMakeFiles/sandbox.dir/src/Service/userService.cpp.o] Błąd 1
make[2]: *** [CMakeFiles/Makefile2:81: CMakeFiles/sandbox.dir/all] Błąd 2
make[1]: *** [CMakeFiles/Makefile2:88: CMakeFiles/sandbox.dir/rule] Błąd 2
make: *** [Makefile:186: sandbox] Błąd 2


mam taką strukturę projektu:

├── CMakeLists.txt
├── include
│   ├── authSecurity.h
│   ├── globals.h
│   ├── passwordEncoder.h
│   ├── rootEndpoint.h
│   ├── routerService.h
│   ├── SandboxExceptions.h
│   ├── serializerService.h
│   ├── tokenSecurity.h
│   ├── userEndpoint.h
│   ├── user.h
│   └── userService.h
├── lib
│   ├── libpqxx
│   │   ├── aclocal.m4
│   │   ├── AUTHORS
│   │   ├── autogen.sh
│   │   ├── cmake
│   │   ├── CMakeLists.txt
│   │   ├── config
│   │   ├── configitems
│   │   ├── config-tests
│   │   ├── configure
│   │   ├── configure.ac
│   │   ├── COPYING
│   │   ├── doc
│   │   ├── include
│   │   ├── INSTALL
│   │   ├── libpqxx.pc.in
│   │   ├── Makefile.am
│   │   ├── Makefile.in
│   │   ├── NEWS
│   │   ├── README.md
│   │   ├── README-UPGRADE
│   │   ├── src
│   │   ├── test
│   │   ├── tools
│   │   ├── VERSION
│   │   └── win32
│   ├── pistache
│   │   ├── 404.html
│   │   ├── assets
│   │   ├── CMakeLists.txt
│   │   ├── CMakeModules
│   │   ├── CNAME
│   │   ├── debian
│   │   ├── docs
│   │   ├── examples
│   │   ├── guide
│   │   ├── include
│   │   ├── index.html
│   │   ├── libpistache.pc.in
│   │   ├── LICENSE
│   │   ├── quickstart.html
│   │   ├── README.md
│   │   ├── src
│   │   ├── tests
│   │   ├── third-party
│   │   └── version.txt
│   └── ThorsSerializer
│       ├── ThorSerialize
│       └── ThorsIOUtil
└── src
    ├── Controller
    ├── Endpoint
    │   ├── rootEndpoint.cpp
    │   └── userEndpoint.cpp
    ├── Entity
    │   └── user.cpp
    ├── Handler
    ├── Helper
    │   └── passwordEncoder.cpp
    ├── sandbox.cpp
    ├── Security
    │   ├── authSecurity.cpp
    │   └── tokenSecurity.cpp
    └── Service
        ├── routerService.cpp
        ├── serializerService.cpp
        └── userService.cpp


Jak załączyć bibliotekę pqxx do projektu jak podprojekt?
P-175345
jankowalski25
» 2019-10-10 21:28:57
Kojarzę podobny temat, możesz rzucić okiem: CMake - jeden projekt korzystający z drugiego (biblioteka), automatyczne dostosowywanie. Zgaduję, że coś w stylu add_subdirectory(nazwa_podfolderu) powinno pomóc.

C/C++
add_subdirectory( lib / libpqxx )

include_directories( include lib / libpqxx / include )

target_link_libraries( sandbox pistache pthread pqxx )
Cudzysłów, stringi koniecznie podawaj jako
"jakiś napis"
, inaczej to nie zadziała!
P-175346
nicraM
Temat założony przez niniejszego użytkownika
» 2019-10-11 10:02:57
Dzięki za hinta, tak też robiłem ale nie chciało mi budować :(
Ale robię trochę inaczej, mianowicie zbudowałem sobie te biblioteki i wrzuciłem do katalogu projektu do "libs" (libpqxx.so i libpqxx.a)

Dodając teraz to do cmake:
C/C++
link_directories( $ { CMAKE_CURRENT_SOURCE_DIR } / libs )
find_library( LIB_PQXX pqxx HINTS "${sandbox_SOURCE_DIR}/libs" )


target_link_libraries( sandbox pistache $ { LIB_PQXX } )

się kompiluje i działa ale to wrzuca mi jako bibliotekę shared :(
$ ldd sandbox
       ...
        libpqxx.so => /home/marcin/CLionProjects/sandbox/libs/libpqxx.so (0x00007f803466c000)
       ...

Natomiast ja chcę by biblioteka była wrzucona w kod
C/C++
add_library( LIB_PQXX STATIC IMPORTED )
set_target_properties( LIB_PQXX PROPERTIES IMPORTED_LOCATION $ { CMAKE_CURRENT_SOURCE_DIR } / libs / libpqxx.a )

Próba zbudowania tego kończy się errorami linkera :(
[ 96%] Building CXX object CMakeFiles/sandbox.dir/src/Service/userService.cpp.o
[100%] Linking CXX executable sandbox
/usr/bin/ld: CMakeFiles/sandbox.dir/src/Endpoint/userEndpoint.cpp.o: in function `__static_initialization_and_destruction_0(int, int)':
/home/marcin/CLionProjects/sandbox/lib/libpqxx/include/pqxx/strconv.hxx:104: undefined reference to `pqxx::internal::demangle_type_name[abi:cxx11](char const*)'
/usr/bin/ld: /home/marcin/CLionProjects/sandbox/lib/libpqxx/include/pqxx/strconv.hxx:104: undefined reference to `pqxx::internal::demangle_type_name[abi:cxx11](char const*)'
/usr/bin/ld: /home/marcin/CLionProjects/sandbox/lib/libpqxx/include/pqxx/strconv.hxx:104: undefined reference to `pqxx::internal::demangle_type_name[abi:cxx11](char const*)'
/usr/bin/ld: /home/marcin/CLionProjects/sandbox/lib/libpqxx/include/pqxx/strconv.hxx:104: undefined reference to `pqxx::internal::demangle_type_name[abi:cxx11](char const*)'
/usr/bin/ld: /home/marcin/CLionProjects/sandbox/lib/libpqxx/include/pqxx/strconv.hxx:104: undefined reference to `pqxx::internal::demangle_type_name[abi:cxx11](char const*)'
/usr/bin/ld: CMakeFiles/sandbox.dir/src/Endpoint/userEndpoint.cpp.o:/home/marcin/CLionProjects/sandbox/lib/libpqxx/include/pqxx/strconv.hxx:104: more undefined references to `pqxx::internal::demangle_type_name[abi:cxx11](char const*)' follow
/usr/bin/ld: CMakeFiles/sandbox.dir/src/Service/userService.cpp.o: in function `sandbox::UserService::~UserService()':
/home/marcin/CLionProjects/sandbox/src/Service/userService.cpp:13: undefined reference to `pqxx::connection::dbname() const'
/usr/bin/ld: /home/marcin/CLionProjects/sandbox/src/Service/userService.cpp:14: undefined reference to `pqxx::connection::close()'
/usr/bin/ld: CMakeFiles/sandbox.dir/src/Service/userService.cpp.o: in function `sandbox::UserService::UserService()':
/home/marcin/CLionProjects/sandbox/src/Service/userService.cpp:22: undefined reference to `pqxx::connection::is_open() const'
/usr/bin/ld: /home/marcin/CLionProjects/sandbox/src/Service/userService.cpp:23: undefined reference to `pqxx::connection::dbname() const'
/usr/bin/ld: /home/marcin/CLionProjects/sandbox/src/Service/userService.cpp:25: undefined reference to `pqxx::connection::dbname() const'
/usr/bin/ld: CMakeFiles/sandbox.dir/src/Service/userService.cpp.o: in function `sandbox::UserService::getAllUsers()':
/home/marcin/CLionProjects/sandbox/src/Service/userService.cpp:31: undefined reference to `pqxx::transaction_base::exec(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
/usr/bin/ld: /home/marcin/CLionProjects/sandbox/src/Service/userService.cpp:32: undefined reference to `pqxx::transaction_base::commit()'
/usr/bin/ld: /home/marcin/CLionProjects/sandbox/src/Service/userService.cpp:34: undefined reference to `pqxx::result::size() const'
/usr/bin/ld: /home/marcin/CLionProjects/sandbox/src/Service/userService.cpp:36: undefined reference to `pqxx::result::begin() const'
/usr/bin/ld: /home/marcin/CLionProjects/sandbox/src/Service/userService.cpp:37: undefined reference to `pqxx::row::operator[](char const*) const'
/usr/bin/ld: /home/marcin/CLionProjects/sandbox/src/Service/userService.cpp:37: undefined reference to `pqxx::row::operator[](char const*) const'
/usr/bin/ld: /home/marcin/CLionProjects/sandbox/src/Service/userService.cpp:37: undefined reference to `pqxx::row::operator[](char const*) const'
/usr/bin/ld: CMakeFiles/sandbox.dir/src/Service/userService.cpp.o: in function `sandbox::UserService::getUserById(int const&)':
/home/marcin/CLionProjects/sandbox/src/Service/userService.cpp:48: undefined reference to `pqxx::transaction_base::exec(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
/usr/bin/ld: /home/marcin/CLionProjects/sandbox/src/Service/userService.cpp:49: undefined reference to `pqxx::transaction_base::commit()'
/usr/bin/ld: /home/marcin/CLionProjects/sandbox/src/Service/userService.cpp:51: undefined reference to `pqxx::result::size() const'
/usr/bin/ld: /home/marcin/CLionProjects/sandbox/src/Service/userService.cpp:52: undefined reference to `pqxx::result::operator[](unsigned long) const'
/usr/bin/ld: /home/marcin/CLionProjects/sandbox/src/Service/userService.cpp:52: undefined reference to `pqxx::row::operator[](char const*) const'
/usr/bin/ld: /home/marcin/CLionProjects/sandbox/src/Service/userService.cpp:52: undefined reference to `pqxx::result::operator[](unsigned long) const'
/usr/bin/ld: /home/marcin/CLionProjects/sandbox/src/Service/userService.cpp:52: undefined reference to `pqxx::row::operator[](char const*) const'
/usr/bin/ld: /home/marcin/CLionProjects/sandbox/src/Service/userService.cpp:52: undefined reference to `pqxx::result::operator[](unsigned long) const'
/usr/bin/ld: /home/marcin/CLionProjects/sandbox/src/Service/userService.cpp:52: undefined reference to `pqxx::row::operator[](char const*) const'
/usr/bin/ld: /home/marcin/CLionProjects/sandbox/src/Service/userService.cpp:55: undefined reference to `pqxx::result::size() const'
/usr/bin/ld: CMakeFiles/sandbox.dir/src/Service/userService.cpp.o: in function `__static_initialization_and_destruction_0(int, int)':
/home/marcin/CLionProjects/sandbox/lib/libpqxx/include/pqxx/strconv.hxx:104: undefined reference to `pqxx::internal::demangle_type_name[abi:cxx11](char const*)'
/usr/bin/ld: /home/marcin/CLionProjects/sandbox/lib/libpqxx/include/pqxx/strconv.hxx:104: undefined reference to `pqxx::internal::demangle_type_name[abi:cxx11](char const*)'
/usr/bin/ld: /home/marcin/CLionProjects/sandbox/lib/libpqxx/include/pqxx/strconv.hxx:104: undefined reference to `pqxx::internal::demangle_type_name[abi:cxx11](char const*)'
/usr/bin/ld: /home/marcin/CLionProjects/sandbox/lib/libpqxx/include/pqxx/strconv.hxx:104: undefined reference to `pqxx::internal::demangle_type_name[abi:cxx11](char const*)'
/usr/bin/ld: /home/marcin/CLionProjects/sandbox/lib/libpqxx/include/pqxx/strconv.hxx:104: undefined reference to `pqxx::internal::demangle_type_name[abi:cxx11](char const*)'
/usr/bin/ld: CMakeFiles/sandbox.dir/src/Service/userService.cpp.o:/home/marcin/CLionProjects/sandbox/lib/libpqxx/include/pqxx/strconv.hxx:104: more undefined references to `pqxx::internal::demangle_type_name[abi:cxx11](char const*)' follow
/usr/bin/ld: CMakeFiles/sandbox.dir/src/Service/userService.cpp.o: in function `pqxx::check_version()':
/home/marcin/CLionProjects/sandbox/lib/libpqxx/include/pqxx/util.hxx:77: undefined reference to `int pqxx::internal::check_library_version<7, 0>()'
/usr/bin/ld: CMakeFiles/sandbox.dir/src/Service/userService.cpp.o: in function `pqxx::connection::connection(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
/home/marcin/CLionProjects/sandbox/lib/libpqxx/include/pqxx/connection.hxx:164: undefined reference to `pqxx::connection::init(char const*)'
/usr/bin/ld: CMakeFiles/sandbox.dir/src/Service/userService.cpp.o: in function `pqxx::connection::~connection()':
/home/marcin/CLionProjects/sandbox/lib/libpqxx/include/pqxx/connection.hxx:187: undefined reference to `pqxx::connection::close()'
/usr/bin/ld: CMakeFiles/sandbox.dir/src/Service/userService.cpp.o: in function `std::enable_if<(!std::is_pointer<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >::value)||std::is_same<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, char const*>::value, bool>::type pqxx::field::to<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&) const':
/home/marcin/CLionProjects/sandbox/lib/libpqxx/include/pqxx/field.hxx:225: undefined reference to `pqxx::field::c_str() const'
/usr/bin/ld: /home/marcin/CLionProjects/sandbox/lib/libpqxx/include/pqxx/field.hxx:226: undefined reference to `pqxx::field::is_null() const'
/usr/bin/ld: /home/marcin/CLionProjects/sandbox/lib/libpqxx/include/pqxx/field.hxx:227: undefined reference to `pqxx::field::size() const'
/usr/bin/ld: CMakeFiles/sandbox.dir/src/Service/userService.cpp.o: in function `pqxx::const_result_iterator::const_result_iterator(pqxx::result const*, unsigned long)':
/home/marcin/CLionProjects/sandbox/lib/libpqxx/include/pqxx/result_iterator.hxx:115: undefined reference to `pqxx::row::row(pqxx::result, unsigned long)'
/usr/bin/ld: CMakeFiles/sandbox.dir/src/Service/userService.cpp.o: in function `pqxx::result::end() const':
/home/marcin/CLionProjects/sandbox/lib/libpqxx/include/pqxx/result_iterator.hxx:228: undefined reference to `pqxx::result::size() const'
/usr/bin/ld: CMakeFiles/sandbox.dir/src/Service/userService.cpp.o: in function `pqxx::dbtransaction::~dbtransaction()':
/home/marcin/CLionProjects/sandbox/lib/libpqxx/include/pqxx/dbtransaction.hxx:52: undefined reference to `pqxx::transaction_base::~transaction_base()'
/usr/bin/ld: CMakeFiles/sandbox.dir/src/Service/userService.cpp.o: in function `pqxx::transaction<(pqxx::isolation_level)0, (pqxx::write_policy)1>::~transaction()':
/home/marcin/CLionProjects/sandbox/lib/libpqxx/include/pqxx/transaction.hxx:87: undefined reference to `pqxx::transaction_base::close()'
/usr/bin/ld: CMakeFiles/sandbox.dir/src/Service/userService.cpp.o: in function `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > pqxx::field::as<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >() const':
/home/marcin/CLionProjects/sandbox/lib/libpqxx/include/pqxx/field.hxx:180: undefined reference to `pqxx::internal::throw_null_conversion(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
/usr/bin/ld: CMakeFiles/sandbox.dir/src/Service/userService.cpp.o: in function `int pqxx::field::as<int>() const':
/home/marcin/CLionProjects/sandbox/lib/libpqxx/include/pqxx/field.hxx:180: undefined reference to `pqxx::internal::throw_null_conversion(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
/usr/bin/ld: CMakeFiles/sandbox.dir/src/Service/userService.cpp.o: in function `pqxx::transaction<(pqxx::isolation_level)0, (pqxx::write_policy)1>::transaction(pqxx::connection&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
/home/marcin/CLionProjects/sandbox/lib/libpqxx/include/pqxx/transaction.hxx:80: undefined reference to `pqxx::internal::basic_transaction::basic_transaction(pqxx::connection&, char const*)'
/usr/bin/ld: CMakeFiles/sandbox.dir/src/Service/userService.cpp.o: in function `std::enable_if<(!std::is_pointer<int>::value)||std::is_same<int, char const*>::value, bool>::type pqxx::field::to<int>(int&) const':
/home/marcin/CLionProjects/sandbox/lib/libpqxx/include/pqxx/field.hxx:130: undefined reference to `pqxx::field::c_str() const'
/usr/bin/ld: /home/marcin/CLionProjects/sandbox/lib/libpqxx/include/pqxx/field.hxx:131: undefined reference to `pqxx::field::is_null() const'
/usr/bin/ld: CMakeFiles/sandbox.dir/src/Service/userService.cpp.o: in function `int pqxx::from_string<int>(std::basic_string_view<char, std::char_traits<char> >)':
/home/marcin/CLionProjects/sandbox/lib/libpqxx/include/pqxx/strconv.hxx:273: undefined reference to `pqxx::internal::builtin_traits<int>::from_string(std::basic_string_view<char, std::char_traits<char> >)'
/usr/bin/ld: CMakeFiles/sandbox.dir/src/Service/userService.cpp.o:(.data.rel.ro._ZTVN4pqxx11transactionILNS_15isolation_levelE0ELNS_12write_policyE1EEE[_ZTVN4pqxx11transactionILNS_15isolation_levelE0ELNS_12write_policyE1EEE]+0x28): undefined reference to `pqxx::internal::basic_transaction::do_commit()'
/usr/bin/ld: CMakeFiles/sandbox.dir/src/Service/userService.cpp.o:(.data.rel.ro._ZTVN4pqxx11transactionILNS_15isolation_levelE0ELNS_12write_policyE1EEE[_ZTVN4pqxx11transactionILNS_15isolation_levelE0ELNS_12write_policyE1EEE]+0x30): undefined reference to `pqxx::internal::basic_transaction::do_abort()'
/usr/bin/ld: CMakeFiles/sandbox.dir/src/Service/userService.cpp.o:(.data.rel.ro._ZTCN4pqxx11transactionILNS_15isolation_levelE0ELNS_12write_policyE1EEE0_NS_8internal17basic_transactionE[_ZTVN4pqxx11transactionILNS_15isolation_levelE0ELNS_12write_policyE1EEE]+0x10): undefined reference to `typeinfo for pqxx::internal::basic_transaction'
/usr/bin/ld: CMakeFiles/sandbox.dir/src/Service/userService.cpp.o:(.data.rel.ro._ZTCN4pqxx11transactionILNS_15isolation_levelE0ELNS_12write_policyE1EEE0_NS_8internal17basic_transactionE[_ZTVN4pqxx11transactionILNS_15isolation_levelE0ELNS_12write_policyE1EEE]+0x28): undefined reference to `pqxx::internal::basic_transaction::do_commit()'
/usr/bin/ld: CMakeFiles/sandbox.dir/src/Service/userService.cpp.o:(.data.rel.ro._ZTCN4pqxx11transactionILNS_15isolation_levelE0ELNS_12write_policyE1EEE0_NS_8internal17basic_transactionE[_ZTVN4pqxx11transactionILNS_15isolation_levelE0ELNS_12write_policyE1EEE]+0x30): undefined reference to `pqxx::internal::basic_transaction::do_abort()'
/usr/bin/ld: CMakeFiles/sandbox.dir/src/Service/userService.cpp.o:(.data.rel.ro._ZTIN4pqxx11transactionILNS_15isolation_levelE0ELNS_12write_policyE1EEE[_ZTIN4pqxx11transactionILNS_15isolation_levelE0ELNS_12write_policyE1EEE]+0x10): undefined reference to `typeinfo for pqxx::internal::basic_transaction'
collect2: error: ld returned 1 exit status
make[3]: *** [CMakeFiles/sandbox.dir/build.make:259: sandbox] Błąd 1
make[2]: *** [CMakeFiles/Makefile2:78: CMakeFiles/sandbox.dir/all] Błąd 2
make[1]: *** [CMakeFiles/Makefile2:85: CMakeFiles/sandbox.dir/rule] Błąd 2
make: *** [Makefile:186: sandbox] Błąd 2

już się pogubiłem :/

P-175347
jankowalski25
» 2019-10-11 18:03:23
Ale robię trochę inaczej, mianowicie zbudowałem sobie te biblioteki i wrzuciłem do katalogu projektu do "libs" (libpqxx.so i libpqxx.a)
Actually CMake's default is to search first for shared libraries and then for static libraries.
Czyli domyślnie CMake najpierw próbuje linkować dynamicznie, a dopiero później statycznie. Jeśli nie musisz wsadzać obu typów bibliotek do jednego folderu, to tego nie rób, wsadź je do dwóch osobnych i po prostu wskaż właściwy folder, gdzie będą biblioteki linkowane tylko statycznie albo tylko dynamicznie. Niby da się jeszcze pokombinować z jawnym wskazywaniem rozszerzeń plików, ale to jest nieprzenośne, więc lepiej tak nie robić.
P-175348
nicraM
Temat założony przez niniejszego użytkownika
» 2019-10-13 08:01:53
Dzięki, za pomoc i hinta. Wyrzuciłem shareowane biblioteki ze wskazywanego katalogu i faktycznie cmake linkuje statyczne ale niestety mam błąd z tej biblioteki
[100%] Linking CXX executable sandbox
/usr/bin/ld: ../libs/libpqxx.a(connection.cxx.o): in function `pqxx::encrypt_password[abi:cxx11](char const*, char const*)':
connection.cxx:(.text+0x87): undefined reference to `PQencryptPassword'
/usr/bin/ld: ../libs/libpqxx.a(connection.cxx.o): in function `pqxx::connection::init(char const*)':
connection.cxx:(.text+0x22a): undefined reference to `PQconnectdb'
/usr/bin/ld: connection.cxx:(.text+0x27d): undefined reference to `PQstatus'
/usr/bin/ld: connection.cxx:(.text+0x2ae): undefined reference to `PQerrorMessage'
/usr/bin/ld: connection.cxx:(.text+0x36e): undefined reference to `PQfinish'
/usr/bin/ld: ../libs/libpqxx.a(connection.cxx.o): in function `pqxx::connection::backendpid() const':
connection.cxx:(.text+0x969): undefined reference to `PQbackendPID'
/usr/bin/ld: ../libs/libpqxx.a(connection.cxx.o): in function `(anonymous namespace)::socket_of(pg_conn const*)':
connection.cxx:(.text+0x991): undefined reference to `PQsocket'
/usr/bin/ld: ../libs/libpqxx.a(connection.cxx.o): in function `pqxx::connection::protocol_version() const':
connection.cxx:(.text+0x9df): undefined reference to `PQprotocolVersion'
/usr/bin/ld: ../libs/libpqxx.a(connection.cxx.o): in function `pqxx::connection::server_version() const':
connection.cxx:(.text+0xa03): undefined reference to `PQserverVersion'
/usr/bin/ld: ../libs/libpqxx.a(connection.cxx.o): in function `pqxx::connection::trace(_IO_FILE*)':
connection.cxx:(.text+0x1423): undefined reference to `PQtrace'
/usr/bin/ld: connection.cxx:(.text+0x1434): undefined reference to `PQuntrace'
/usr/bin/ld: ../libs/libpqxx.a(connection.cxx.o): in function `pqxx::connection::add_receiver(pqxx::notification_receiver*)':
connection.cxx:(.text+0x15e8): undefined reference to `PQexec'
/usr/bin/ld: ../libs/libpqxx.a(connection.cxx.o): in function `pqxx::connection::consume_input()':
connection.cxx:(.text+0x1a5d): undefined reference to `PQconsumeInput'
/usr/bin/ld: ../libs/libpqxx.a(connection.cxx.o): in function `pqxx::connection::is_busy() const':
connection.cxx:(.text+0x1a7f): undefined reference to `PQisBusy'
/usr/bin/ld: ../libs/libpqxx.a(connection.cxx.o): in function `(anonymous namespace)::cancel_wrapper::cancel_wrapper(pg_conn*)':
connection.cxx:(.text+0x1ad6): undefined reference to `PQgetCancel'
/usr/bin/ld: ../libs/libpqxx.a(connection.cxx.o): in function `(anonymous namespace)::cancel_wrapper::~cancel_wrapper()':
connection.cxx:(.text+0x1b49): undefined reference to `PQfreeCancel'
/usr/bin/ld: ../libs/libpqxx.a(connection.cxx.o): in function `(anonymous namespace)::cancel_wrapper::operator()()':
connection.cxx:(.text+0x1b99): undefined reference to `PQcancel'
/usr/bin/ld: ../libs/libpqxx.a(connection.cxx.o): in function `pqxx::connection::set_verbosity(pqxx::error_verbosity)':
connection.cxx:(.text+0x1d89): undefined reference to `PQsetErrorVerbosity'
/usr/bin/ld: ../libs/libpqxx.a(connection.cxx.o): in function `(anonymous namespace)::get_notif(pg_conn*)':
connection.cxx:(.text+0x1dcb): undefined reference to `PQnotifies'
/usr/bin/ld: ../libs/libpqxx.a(connection.cxx.o): in function `pqxx::connection::dbname() const':
connection.cxx:(.text+0x23b1): undefined reference to `PQdb'
/usr/bin/ld: ../libs/libpqxx.a(connection.cxx.o): in function `pqxx::connection::username() const':
connection.cxx:(.text+0x23cf): undefined reference to `PQuser'
/usr/bin/ld: ../libs/libpqxx.a(connection.cxx.o): in function `pqxx::connection::hostname() const':
connection.cxx:(.text+0x23ed): undefined reference to `PQhost'
/usr/bin/ld: ../libs/libpqxx.a(connection.cxx.o): in function `pqxx::connection::port() const':
connection.cxx:(.text+0x240b): undefined reference to `PQport'
/usr/bin/ld: ../libs/libpqxx.a(connection.cxx.o): in function `pqxx::connection::err_msg() const':
connection.cxx:(.text+0x2435): undefined reference to `PQerrorMessage'
/usr/bin/ld: ../libs/libpqxx.a(connection.cxx.o): in function `pqxx::connection::clear_notice_processor()':
connection.cxx:(.text+0x2467): undefined reference to `PQsetNoticeProcessor'
/usr/bin/ld: ../libs/libpqxx.a(connection.cxx.o): in function `pqxx::connection::set_notice_processor()':
connection.cxx:(.text+0x2490): undefined reference to `PQsetNoticeProcessor'
/usr/bin/ld: ../libs/libpqxx.a(connection.cxx.o): in function `pqxx::connection::exec(char const*)':
connection.cxx:(.text+0x263b): undefined reference to `PQexec'
/usr/bin/ld: ../libs/libpqxx.a(connection.cxx.o): in function `pqxx::connection::prepare(char const*, char const*)':
connection.cxx:(.text+0x2774): undefined reference to `PQprepare'
/usr/bin/ld: ../libs/libpqxx.a(connection.cxx.o): in function `pqxx::connection::exec_prepared(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, pqxx::internal::params const&)':
connection.cxx:(.text+0x2a25): undefined reference to `PQexecPrepared'
/usr/bin/ld: ../libs/libpqxx.a(connection.cxx.o): in function `pqxx::connection::close()':
connection.cxx:(.text+0x2cd0): undefined reference to `PQfinish'
/usr/bin/ld: ../libs/libpqxx.a(connection.cxx.o): in function `pqxx::connection::status() const':
connection.cxx:(.text+0x2dc1): undefined reference to `PQstatus'
/usr/bin/ld: ../libs/libpqxx.a(connection.cxx.o): in function `pqxx::connection::read_copy_line(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&)':
connection.cxx:(.text+0x2f0a): undefined reference to `PQgetCopyData'
/usr/bin/ld: connection.cxx:(.text+0x2ff0): undefined reference to `PQgetResult'
/usr/bin/ld: connection.cxx:(.text+0x306a): undefined reference to `PQgetResult'
/usr/bin/ld: ../libs/libpqxx.a(connection.cxx.o): in function `pqxx::connection::write_copy_line(std::basic_string_view<char, std::char_traits<char> >)':
connection.cxx:(.text+0x33b2): undefined reference to `PQputCopyData'
/usr/bin/ld: connection.cxx:(.text+0x3436): undefined reference to `PQputCopyData'
/usr/bin/ld: ../libs/libpqxx.a(connection.cxx.o): in function `pqxx::connection::end_copy_write()':
connection.cxx:(.text+0x3575): undefined reference to `PQputCopyEnd'
/usr/bin/ld: connection.cxx:(.text+0x3791): undefined reference to `PQgetResult'
/usr/bin/ld: ../libs/libpqxx.a(connection.cxx.o): in function `pqxx::connection::start_exec(char const*)':
connection.cxx:(.text+0x3962): undefined reference to `PQsendQuery'
/usr/bin/ld: ../libs/libpqxx.a(connection.cxx.o): in function `pqxx::connection::get_result()':
connection.cxx:(.text+0x3a53): undefined reference to `PQgetResult'
/usr/bin/ld: ../libs/libpqxx.a(connection.cxx.o): in function `pqxx::connection::esc[abi:cxx11](std::basic_string_view<char, std::char_traits<char> >) const':
connection.cxx:(.text+0x3b1d): undefined reference to `PQescapeStringConn'
/usr/bin/ld: ../libs/libpqxx.a(connection.cxx.o): in function `pqxx::connection::esc_raw[abi:cxx11](unsigned char const*, unsigned long) const':
connection.cxx:(.text+0x3cd2): undefined reference to `PQescapeByteaConn'
/usr/bin/ld: ../libs/libpqxx.a(connection.cxx.o): in function `pqxx::connection::unesc_raw[abi:cxx11](char const*) const':
connection.cxx:(.text+0x3e32): undefined reference to `PQunescapeBytea'
/usr/bin/ld: ../libs/libpqxx.a(connection.cxx.o): in function `pqxx::connection::quote_name[abi:cxx11](std::basic_string_view<char, std::char_traits<char> >) const':
connection.cxx:(.text+0x40d3): undefined reference to `PQescapeIdentifier'
/usr/bin/ld: ../libs/libpqxx.a(connection.cxx.o): in function `pqxx::connection::set_client_encoding(char const*)':
connection.cxx:(.text+0x4c62): undefined reference to `PQsetClientEncoding'
/usr/bin/ld: ../libs/libpqxx.a(connection.cxx.o): in function `pqxx::connection::encoding_id() const':
connection.cxx:(.text+0x4e0f): undefined reference to `PQclientEncoding'
/usr/bin/ld: ../libs/libpqxx.a(connection.cxx.o): in function `pqxx::connection::exec_params(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, pqxx::internal::params const&)':
connection.cxx:(.text+0x4f92): undefined reference to `PQexecParams'
/usr/bin/ld: ../libs/libpqxx.a(encodings.cxx.o): in function `pqxx::internal::name_encoding(int)':
encodings.cxx:(.text+0x1914): undefined reference to `pg_encoding_to_char'
/usr/bin/ld: ../libs/libpqxx.a(result.cxx.o): in function `pqxx::internal::clear_result(pg_result const*)':
result.cxx:(.text+0x2a): undefined reference to `PQclear'
/usr/bin/ld: ../libs/libpqxx.a(result.cxx.o): in function `pqxx::result::size() const':
result.cxx:(.text+0x423): undefined reference to `PQntuples'
/usr/bin/ld: ../libs/libpqxx.a(result.cxx.o): in function `pqxx::result::empty() const':
result.cxx:(.text+0x45f): undefined reference to `PQntuples'
/usr/bin/ld: ../libs/libpqxx.a(result.cxx.o): in function `pqxx::result::ThrowSQLError(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const':
result.cxx:(.text+0x780): undefined reference to `PQresultErrorField'
/usr/bin/ld: ../libs/libpqxx.a(result.cxx.o): in function `pqxx::result::StatusError[abi:cxx11]() const':
result.cxx:(.text+0x14ff): undefined reference to `PQresultStatus'
/usr/bin/ld: result.cxx:(.text+0x153a): undefined reference to `PQresultErrorMessage'
/usr/bin/ld: result.cxx:(.text+0x1572): undefined reference to `PQresultStatus'
/usr/bin/ld: ../libs/libpqxx.a(result.cxx.o): in function `pqxx::result::cmd_status() const':
result.cxx:(.text+0x16a4): undefined reference to `PQcmdStatus'
/usr/bin/ld: ../libs/libpqxx.a(result.cxx.o): in function `pqxx::result::inserted_oid() const':
result.cxx:(.text+0x1797): undefined reference to `PQoidValue'
/usr/bin/ld: ../libs/libpqxx.a(result.cxx.o): in function `pqxx::result::affected_rows() const':
result.cxx:(.text+0x180a): undefined reference to `PQcmdTuples'
/usr/bin/ld: ../libs/libpqxx.a(result.cxx.o): in function `pqxx::result::GetValue(unsigned long, unsigned int) const':
result.cxx:(.text+0x1869): undefined reference to `PQgetvalue'
/usr/bin/ld: ../libs/libpqxx.a(result.cxx.o): in function `pqxx::result::get_is_null(unsigned long, unsigned int) const':
result.cxx:(.text+0x18ab): undefined reference to `PQgetisnull'
/usr/bin/ld: ../libs/libpqxx.a(result.cxx.o): in function `pqxx::result::get_length(unsigned long, unsigned int) const':
result.cxx:(.text+0x18f7): undefined reference to `PQgetlength'
/usr/bin/ld: ../libs/libpqxx.a(result.cxx.o): in function `pqxx::result::column_type(unsigned int) const':
result.cxx:(.text+0x194d): undefined reference to `PQftype'
/usr/bin/ld: ../libs/libpqxx.a(result.cxx.o): in function `pqxx::result::column_table(unsigned int) const':
result.cxx:(.text+0x1ab9): undefined reference to `PQftable'
/usr/bin/ld: ../libs/libpqxx.a(result.cxx.o): in function `pqxx::result::table_column(unsigned int) const':
result.cxx:(.text+0x1cd9): undefined reference to `PQftablecol'
/usr/bin/ld: ../libs/libpqxx.a(result.cxx.o): in function `pqxx::result::errorposition() const':
result.cxx:(.text+0x1f9f): undefined reference to `PQresultErrorField'
/usr/bin/ld: ../libs/libpqxx.a(result.cxx.o): in function `pqxx::result::column_name(unsigned int) const':
result.cxx:(.text+0x2037): undefined reference to `PQfname'
/usr/bin/ld: ../libs/libpqxx.a(result.cxx.o): in function `pqxx::result::columns() const':
result.cxx:(.text+0x2331): undefined reference to `PQnfields'
/usr/bin/ld: ../libs/libpqxx.a(row.cxx.o): in function `pqxx::result::column_number(char const*) const':
row.cxx:(.text+0xa3f): undefined reference to `PQfnumber'
/usr/bin/ld: ../libs/libpqxx.a(util.cxx.o): in function `pqxx::describe_thread_safety()':
util.cxx:(.text+0x28): undefined reference to `PQisthreadsafe'
/usr/bin/ld: ../libs/libpqxx.a(util.cxx.o): in function `pqxx::internal::freepqmem(void const*)':
util.cxx:(.text+0x97c): undefined reference to `PQfreemem'
collect2: error: ld returned 1 exit status
make[3]: *** [CMakeFiles/sandbox.dir/build.make:260: sandbox] Błąd 1
make[2]: *** [CMakeFiles/Makefile2:78: CMakeFiles/sandbox.dir/all] Błąd 2
make[1]: *** [CMakeFiles/Makefile2:85: CMakeFiles/sandbox.dir/rule] Błąd 2
make: *** [Makefile:186: sandbox] Błąd 2
przy shared jest wszystko ok
P-175351
« 1 »
  Strona 1 z 1