cmake 및 libldap을 사용하는 이상한 연결 문제

cmake 및 libldap을 사용하는 이상한 연결 문제

download_an_compile.sh 스크립트(CMake를 사용하여 바이너리를 빌드함)를 사용하여 FlightGear 프로젝트에서 SimGear를 빌드하려고 합니다. 지금까지는 빌드가 잘 진행되고 있지만 스크립트가 빌드된 개체 파일을 라이브러리에 연결하려고 하면 수많은 메시지를 받습니다.

//usr/lib/x86_64-linux-gnu/libldap_r-2.4.so.2: warning: undefined reference to [email protected]_2

(여기서 ...는 각 메시지마다 다른 함수 이름입니다). 이제 -DCMAKE_CXX_STANDARD_LIBRARIES="-llber-2.4"CMake에 매개변수를 추가하여 Lber 라이브러리를 빌드 중인 라이브러리에 연결하도록 CMake에 수동으로 지시 해야 한다고 생각합니다 . 이로 인해

/usr/bin/ld: -llber-2.4 could not be found

이것이 바로 거기에 있기 때문에 나에게는 미스터리입니다.

$ ls /usr/lib/x86_64-linux-gnu | grep lber
liblber-2.4.so.2
liblber-2.4.so.2.10.8

실제로 undefined reference다음 함수가 있기 때문에 오류가 발생해서는 안 됩니다.

$ nm /usr/lib/x86_64-linux-gnu/liblber-2.4.so.2 

$ nm -D /usr/lib/x86_64-linux-gnu/liblber-2.4.so.2 | grep ber
0000000000005fe0 T ber_alloc
0000000000005fa0 T ber_alloc_t
0000000000006d50 T ber_bprint
0000000000007ec0 T ber_bvarray_add
0000000000007df0 T ber_bvarray_add_x
0000000000007cd0 T ber_bvarray_dup_x
0000000000007cc0 T ber_bvarray_free
0000000000007c30 T ber_bvarray_free_x
0000000000007830 T ber_bvdup
0000000000007700 T ber_bvecadd
0000000000007650 T ber_bvecadd_x
0000000000007640 T ber_bvecfree
00000000000075c0 T ber_bvecfree_x
00000000000075b0 T ber_bvfree
0000000000007570 T ber_bvfree_x
0000000000007c20 T ber_bvreplace
0000000000007b80 T ber_bvreplace_x
0000000000002c70 T ber_decode_oid
0000000000006fc0 T ber_dump
0000000000006000 T ber_dup
0000000000007820 T ber_dupbv
0000000000007710 T ber_dupbv_x
0000000000004cc0 T ber_encode_oid
0000000000006ab0 T ber_errno_addr
0000000000006a30 T ber_error_print
0000000000003a80 T ber_first_element
0000000000006250 T ber_flatten
0000000000006170 T ber_flatten2
0000000000005f90 T ber_flush
0000000000005db0 T ber_flush2
0000000000005d70 T ber_free
0000000000005d10 T ber_free_buf
00000000000038d0 T ber_get_bitstringa
0000000000003a70 T ber_get_boolean
0000000000003150 T ber_get_enum
0000000000003080 T ber_get_int
0000000000006400 T ber_get_next
0000000000003a20 T ber_get_null
0000000000007ed0 T ber_get_option
0000000000003730 T ber_get_stringa
0000000000003810 T ber_get_stringal
00000000000037a0 T ber_get_stringa_null
0000000000003160 T ber_get_stringb
00000000000031f0 T ber_get_stringbv
0000000000003650 T ber_get_stringbv_null
0000000000002e30 T ber_get_tag
0000000000006380 T ber_init
00000000000060c0 T ber_init2
0000000000006160 T ber_init_w_nullc
000000000020d168 B ber_int_errno_fn
000000000020d178 B ber_int_log_proc
000000000020d190 B ber_int_memory_fns
000000000020d1a0 B ber_int_options
0000000000009590 T ber_int_sb_close
0000000000009610 T ber_int_sb_destroy
0000000000009500 T ber_int_sb_init
0000000000009710 T ber_int_sb_read
00000000000099e0 T ber_int_sb_write
00000000000069d0 T ber_len
0000000000006f70 T ber_log_bprint
00000000000070b0 T ber_log_dump
0000000000007120 T ber_log_sos_dump
0000000000007a50 T ber_mem2bv
0000000000007950 T ber_mem2bv_x
0000000000007460 T ber_memalloc
0000000000007400 T ber_memalloc_x
00000000000074d0 T ber_memcalloc
0000000000007470 T ber_memcalloc_x
0000000000007390 T ber_memfree
0000000000007330 T ber_memfree_x
0000000000007560 T ber_memrealloc
00000000000074e0 T ber_memrealloc_x
00000000000073f0 T ber_memvfree
00000000000073a0 T ber_memvfree_x
0000000000003b00 T ber_next_element
0000000000002e80 T ber_peek_element
0000000000002fd0 T ber_peek_tag
0000000000005370 T ber_printf
00000000000069e0 T ber_ptrlen
0000000000005080 T ber_put_berval
0000000000005100 T ber_put_bitstring
0000000000005290 T ber_put_boolean
0000000000004f30 T ber_put_enum
0000000000004f50 T ber_put_int
0000000000005220 T ber_put_null
0000000000004f70 T ber_put_ostring
0000000000005350 T ber_put_seq
0000000000005360 T ber_put_set
00000000000050b0 T ber_put_string
000000000020d170 B ber_pvt_err_file
0000000000006ad0 T ber_pvt_log_output
000000000020d008 D ber_pvt_log_print
0000000000006c20 T ber_pvt_log_printf
000000000020d1e0 B ber_pvt_opt_on
0000000000008f00 T ber_pvt_sb_buf_destroy
0000000000008ee0 T ber_pvt_sb_buf_init
0000000000009180 T ber_pvt_sb_copy_out
00000000000093b0 T ber_pvt_sb_do_write
0000000000008fe0 T ber_pvt_sb_grow_buffer
00000000000094c0 T ber_pvt_socket_set_nonblock
0000000000005a20 T ber_read
0000000000005ad0 T ber_realloc
0000000000006a20 T ber_remaining
00000000000062f0 T ber_reset
00000000000069f0 T ber_rewind
0000000000003ba0 T ber_scanf
00000000000080f0 T ber_set_option
00000000000059a0 T ber_skip_data
0000000000002f90 T ber_skip_element
0000000000003020 T ber_skip_tag
0000000000008d30 T ber_sockbuf_add_io
0000000000009560 T ber_sockbuf_alloc
0000000000009800 T ber_sockbuf_ctrl
00000000000096a0 T ber_sockbuf_free
000000000020d060 D ber_sockbuf_io_debug
000000000020d0a0 D ber_sockbuf_io_fd
000000000020d0e0 D ber_sockbuf_io_readahead
000000000020d120 D ber_sockbuf_io_tcp
000000000020d020 D ber_sockbuf_io_udp
0000000000008e20 T ber_sockbuf_remove_io
0000000000007130 T ber_sos_dump
00000000000069c0 T ber_start
0000000000005310 T ber_start_seq
0000000000005330 T ber_start_set
0000000000007940 T ber_str2bv
0000000000007840 T ber_str2bv_x
0000000000007ac0 T ber_strdup
0000000000007a60 T ber_strdup_x
0000000000007b70 T ber_strndup
0000000000007b10 T ber_strndup_x
0000000000007ad0 T ber_strnlen
0000000000005c00 T ber_write

lddlibldap또한 오른쪽이 참조되고 있음 을 보여줍니다 liblber.

$ ldd /usr/lib/x86_64-linux-gnu/libldap_r-2.4.so.2 | grep lber
    liblber-2.4.so.2 => /usr/lib/x86_64-linux-gnu/liblber-2.4.so.2 (0x00007f28c8bdc000)

누구든지 어떤 아이디어가 있습니까? 아니요... 세부 사항을 잊어버린 경우 알려주시면 추가하겠습니다!

답변1

적어도 데비안(및 그 파생물)에서는 공유 라이브러리의개발 파일별도의 바이너리 패키지로 분할:

공유 라이브러리와 연결된 개발 파일이 있는 경우 소스 코드 패키지는 libraryname-dev라는 바이너리 개발 패키지를 생성해야 하며, 한 번에 여러 개발 버전을 지원해야 하는 경우 librarynameapiversion-dev를 생성해야 합니다. 개발 패키지를 설치하려면 공유 라이브러리에 대해 프로그램을 컴파일하는 데 필요한 모든 개발 파일을 설치해야 합니다.

이 경우 "개발 파일"은 주로 C/C++ 헤더 파일을 참조하지만 중요한 것은 종종 공유 라이브러리 자체에 대한 심볼릭 링크를 포함하는 경우가 많습니다.

개발 패키지에는 버전 번호 없이 연관된 공유 라이브러리에 대한 기호 링크가 포함되어야 합니다. 예를 들어, libgdbm-dev 패키지에는 /usr/lib/libgdbm.so에서 libgdbm.so.3.0.0으로의 심볼릭 링크가 포함되어 있어야 합니다. 링커(ld)는 동적으로 컴파일할 때 libgdbm.so만 찾기 때문에 패키지를 컴파일할 때 이 기호 링크가 필요합니다.

이 경우 이미 공유 라이브러리가 있지만

liblber-2.4.so.2
liblber-2.4.so.2.10.8

그런데 해당 개발 패키지에서 제공하는 /usr/lib/x86_64-linux-gnu심볼릭 링크가 없는 것 같습니다 ./usr/lib/x86_64-linux-gnu/liblber.solibldap2-dev

관련 정보