tdlib-json-cli icon indicating copy to clipboard operation
tdlib-json-cli copied to clipboard

Error: linker command failed with exit code 1

Open alex9spiridonov opened this issue 3 years ago • 3 comments

When I run make -j4 on my macOS I get error

clang: error: linker command failed with exit code 1 (use -v to see invocation)

I get this error on version v1.8.0. With version v1.7.0 everything is fine.

How can this be fixed?

➜  Release git:(master) ✗ make -j4
[  1%] Built target tl-parser
[  1%] Built target generate_mime_types_gperf
[  2%] Built target tdsqlite
[  3%] Built target tdtl
[  3%] Generate git_commit.h
[  4%] Built target tdmime_auto
[  4%] Generate TLO files
[  6%] Built target generate_common
[  6%] Built target generate_c
[  7%] Built target td_generate_java_api
[  7%] Built target remove_documentation
[  7%] Built target tl_generate_tlo
[  8%] Generate common TL source files
[  8%] Built target git_commit
[ 25%] Built target tdutils
[ 26%] Built target memprof
[ 27%] Built target generate_json
[ 28%] Built target tdactor
[ 28%] Built target bench_crypto
[ 28%] Built target check_tls
[ 29%] Built target rmdir
[ 29%] Built target bench_empty
[ 29%] Built target bench_log
[ 30%] Built target bench_queue
[ 30%] Generate JSON TL source files
[ 34%] Built target tddb
[ 37%] Built target tdnet
[ 37%] Built target tl_generate_json
[ 38%] Built target example
[ 39%] Built target binlog_dump
[ 39%] Built target bench_actor
[ 39%] Built target bench_http
[ 40%] Built target bench_http_server
[ 40%] Built target bench_http_server_cheat
[ 41%] Built target bench_http_server_fast
[ 41%] Built target bench_http_reader
[ 42%] Built target bench_db
[ 42%] Built target tl_generate_common
[ 43%] Built target wget
[ 43%] Built target tdapi
[ 85%] Built target tdcore
[ 86%] Built target bench_handshake
[ 86%] Built target bench_tddb
[ 86%] Built target tdclient
[ 86%] Built target bench_misc
[ 86%] Built target tdjson_private
[ 86%] Built target check_proxy
[ 86%] Built target tg_cli
[ 87%] Built target tdjson_static
[ 89%] Built target tdjson
[ 89%] Linking CXX executable bin/tdlib_json_cli
[100%] Built target run_all_tests
clang: warning: argument unused during compilation: '-static-libgcc' [-Wunused-command-line-argument]
clang: warning: argument unused during compilation: '-static-libstdc++' [-Wunused-command-line-argument]
ld: library not found for -lcrt0.o
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [bin/tdlib_json_cli] Error 1
make[1]: *** [CMakeFiles/tdlib_json_cli.dir/all] Error 2
make: *** [all] Error 2

alex9spiridonov avatar Jun 09 '22 10:06 alex9spiridonov

I solved this problem. I replaced

set(CMAKE_EXE_LINKER_FLAGS " -static")
target_link_libraries(tdlib_json_cli Td::TdJsonStatic -static-libgcc -static-libstdc++)

to

target_link_libraries(tdlib_json_cli Td::TdJsonStatic)

i.e. just removed static links at CMakeLists.txt

alex9spiridonov avatar Jun 09 '22 12:06 alex9spiridonov

Why logic with static was added to project? Can we omit it?

alex9spiridonov avatar Jun 15 '22 08:06 alex9spiridonov

Why logic with static was added to project?

Static link can produce static-linked binary, which can distribute between machines without version-specificed libraries installed.

oott123 avatar Jun 15 '22 09:06 oott123