I am porting an application on Solaris 11_x86 system. When I compile it using `make, I get these errors:
Linking <application>...
collect2: ld terminated with signal 8 [Arithmetic Exception], core dumped
ld: warning: global symbol `_END_' has non-global binding:
(file /usr/local/ssl/lib/libssl.so value=LOCL);
ld: warning: global symbol `_START_' has non-global binding:
(file /usr/local/ssl/lib/libssl.so value=LOCL);
make: *** [sosd] Error 1
How do I fix this?
Related
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.0: in function '_start' :
(.text+0x24): undefined reference to 'main'
Collect2: error: ld returned to 1 exit status
If you're using CMake check if you're really compiling a library not an executable. This error can occur if you have
add_executable(${PROJECT_NAME} ${SOURCES})
instead of
add_library(${PROJECT_NAME} ${SOURCES})
The latter should compile a library; a library doesn't have the main().
i am using Xilinx SDK with cross compiler as aarch64-none-elf-gcc
i am loading a shared library in my program and i am getting error as
Building target: fsbl.elf
Invoking: ARM v8 gcc linker
aarch64-none-elf-gcc -L"/proj/ssw_xhd/boot/balakrish/workspace/hello_world/Debug" -Lwrk/released/2017.3/GA/2017.3_1005_1/installs/lin64/SDK/2017.3/gnu/aarch64/lin/aarch64-none/bin/../lib/gcc/aarch64-none-elf/6.2.1/../../../../aarch64-none-elf/bin/ld -Wl,-T -Wl,../src/lscript.ld -L../../fsbl_bsp/psu_cortexa53_0/lib -o "fsbl.elf" ./src/psu_init.o ./src/xfsbl_authentication.o ./src/xfsbl_board.o ./src/xfsbl_bs.o ./src/xfsbl_csu_dma.o ./src/xfsbl_dfu_util.o ./src/xfsbl_exit.o ./src/xfsbl_handoff.o ./src/xfsbl_hooks.o ./src/xfsbl_image_header.o ./src/xfsbl_initialization.o ./src/xfsbl_main.o ./src/xfsbl_misc.o ./src/xfsbl_misc_drivers.o ./src/xfsbl_nand.o ./src/xfsbl_partition_load.o ./src/xfsbl_plpartition_valid.o ./src/xfsbl_qspi.o ./src/xfsbl_rsa_sha.o ./src/xfsbl_sd.o ./src/xfsbl_translation_table.o ./src/xfsbl_usb.o -lhello -Wl,--start-group,-lxil,-lgcc,-lc,--end-group -Wl,--start-group,-lxilffs,-lxil,-lgcc,-lc,--end-group -Wl,--start-group,-lxilsecure,-lxil,-lgcc,-lc,--end-group -Wl,--start-group,-lxilpm,-lxil,-lgcc,-lc,--end-group -n
/tmp/ccjtx6CQ.ltrans0.ltrans.o: In function `main':
<artificial>:(.text.startup+0x18c): undefined reference to `dlopen'
<artificial>:(.text.startup+0x18c): relocation truncated to fit: R_AARCH64_CALL26 against undefined symbol `dlopen'
<artificial>:(.text.startup+0x19c): undefined reference to `dlsym'
<artificial>:(.text.startup+0x19c): relocation truncated to fit: R_AARCH64_CALL26 against undefined symbol `dlsym'
<artificial>:(.text.startup+0x1a4): undefined reference to `library_function'
<artificial>:(.text.startup+0x1a4): relocation truncated to fit: R_AARCH64_CALL26 against undefined symbol `library_function'
<artificial>:(.text.startup+0x1ac): undefined reference to `dlclose'
<artificial>:(.text.startup+0x1ac): relocation truncated to fit: R_AARCH64_CALL26 against undefined symbol `dlclose'
collect2: error: ld returned 1 exit status
make: *** [fsbl.elf] Error 1
Finally my question is how to load -ldl in cross compiling
if i use -ldl in C/C++ Build settings-.libraries->library paths . I am getting error as
/wrk/released/2017.3/GA/2017.3_1005_1/installs/lin64/SDK/2017.3/gnu/aarch64/lin/aarch64-none/bin/../lib/gcc/aarch64-none-elf/6.2.1/../../../../aarch64-none-elf/bin/ld: cannot find -ldl
collect2: error: ld returned 1 exit status
make: *** [fsbl.elf] Error 1
Different parts of your answer seem to conflict.
dlopen, dlsym and friends are used to load code from another file on the filesystem. In other words, these functions are related to loading code, at runtime, from a library available on the target platform filesystem and operating system.
In the case of cross compiling, the toolchain needs to provide the library (libdl.so or libdl.a) that has the implementaiton of those functions. The toolchain provide the code that has the relevant operating system calls to open the file with the code, map it to memory and link it into the running program.
Which is where the conflict comes into play. The toolchain you mention seems to be bare metal toolchain. In other words, this is a tool chain for running your code directly on the chip, with no operating system. If you have no operating system, it should be obvious that you cannot use it in order to load further code at runtime.
With that in mind, it should be obvious why the tool chain does not supply you with a suitable implementation of libdl.a. It cannot be generically implemented on the platform.
I've downloaded the latest release of libzip and am currently trying to build it on OSX and failing:
Linking C shared library libzip.dylib
Undefined symbols for architecture x86_64:
"_crc32", referenced from:
__zip_filerange_crc in zip_filerange_crc.o
_crc_read in zip_source_crc.o
_decrypt in zip_source_pkware.o
__zip_string_crc32 in zip_string.o
(maybe you meant: __zip_string_crc32)
"_deflate", referenced from:
_compress_read in zip_source_deflate.o
(maybe you meant: _zip_source_deflate)
"_deflateEnd", referenced from:
_deflate_compress in zip_source_deflate.o
"_deflateInit2_", referenced from:
_deflate_compress in zip_source_deflate.o
"_inflate", referenced from:
_decompress_read in zip_source_deflate.o
"_inflateEnd", referenced from:
_deflate_decompress in zip_source_deflate.o
"_inflateInit2_", referenced from:
_deflate_decompress in zip_source_deflate.o
"_zError", referenced from:
__zip_error_strerror in zip_error_strerror.o
_zip_error_to_str in zip_error_to_str.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[3]: *** [libzip.3.0.dylib] Error 1
make[2]: *** [CMakeFiles/zip.dir/all] Error 2
make[1]: *** [CMakeFiles/zip.dir/rule] Error 2
make: *** [zip] Error 2
It needs a crc32 function but it doesn't include one nor does it seem to link to anything else. Has anyone been able to build libzip on OSX 10.9?
You seem to be missing to link a against libz.
Get the developer files for zlib somewhere and add -lz to the (end of the command line of the) link command.
I am currently trying to install rng-tools on OSX, as I have a specific need for it to speed up a certain simulator that I am currently using. At first, I faced the problem of not having argp, so I installed argp-standalone from Homebrew. However, I still receive the following error message when trying to make rng-tools:
gcc -g -O2 -o rngtest stats.o rngtest.o librngd.a
Undefined symbols for architecture x86_64:
"_argp_parse", referenced from:
_main in rngtest.o
"_argp_usage", referenced from:
_parse_opt in rngtest.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
make[2]: *** [rngtest] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2
I checked /usr/local/include/argp.h and it does seem to contain the correct function definitions referenced in rngtest.c, so any thoughts on what might be the problem?
I just needed rngtest which I managed to compile on OSX using this https://github.com/fproulx/rngtest (which also needs brew install argp-standalone). I made that into a homebrew formula which can be obtained here: https://github.com/oderwat/homebrew-experiments
Am trying to build a c program in netbeans on mac osx 10.7.5 and am getting the following error. I am not sure what is going on. I am trying to learn c.
"/usr/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
nbproject/Makefile-Debug.mk:73: warning: overriding commands for target `build/Debug/GNU-MacOSX/UnsortedList.o'
nbproject/Makefile-Debug.mk:68: warning: ignoring old commands for target `build/Debug/GNU-MacOSX/UnsortedList.o'
"/usr/bin/make" -f nbproject/Makefile-Debug.mk dist/Debug/GNU-MacOSX/cs350_lab6_linkedlist
nbproject/Makefile-Debug.mk:73: warning: overriding commands for target `build/Debug/GNU-MacOSX/UnsortedList.o'
nbproject/Makefile-Debug.mk:68: warning: ignoring old commands for target `build/Debug/GNU-MacOSX/UnsortedList.o'
mkdir -p dist/Debug/GNU-MacOSX
gcc -o dist/Debug/GNU-MacOSX/cs350_lab6_linkedlist build/Debug/GNU-MacOSX/UnsortedList.o build/Debug/GNU-MacOSX/UnsortedList.o build/Debug/GNU-MacOSX/main.o
ld: warning: ignoring file build/Debug/GNU-MacOSX/UnsortedList.o, file was built for unsupported file format which is not the architecture being linked (x86_64)
ld: warning: ignoring file build/Debug/GNU-MacOSX/UnsortedList.o, file was built for unsupported file format which is not the architecture being linked (x86_64)
Undefined symbols for architecture x86_64:
"_CreateList", referenced from:
_main in main.o
"_InsertItem", referenced from:
_main in main.o
"_DeleteItem", referenced from:
_main in main.o
"_PrintList", referenced from:
_main in main.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
make[2]: *** [dist/Debug/GNU-MacOSX/cs350_lab6_linkedlist] Error 1
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2
BUILD FAILED (exit value 2, total time: 71ms)
If i put all the methods definitions in the main file instead of writing separately in implementation file, then it's building fine and showing no error.