linker

Why different memory addresses for a function between direct linking and dlopen

爱⌒轻易说出口 提交于 2020-01-06 05:29:10
问题 When same library is linked and used with dlopen, same function (sqrt in this example) has different memory addresses. Can you please explain why it is so? Is there some indirection? # cat dl-test.c #include <stdio.h> #include <stdlib.h> #include <dlfcn.h> #include <math.h> #include <inttypes.h> int main() { void *dl, *dl_sqrt; dl = dlopen("/lib/x86_64-linux-gnu/libm.so.6", RTLD_LAZY); if (!dl) { fprintf(stderr, "%s\n", dlerror()); exit(1); } dl_sqrt = dlsym(dl,"sqrt"); if (!dl_sqrt) {

Why do I get a linker error while I try to compile a C file?

…衆ロ難τιáo~ 提交于 2020-01-06 05:25:13
问题 I've had this error for weeks I already made a post about it but it wasn't very clear. So I am calling a function from a a header file myBmpGris.h and the functions are implemented on the file myBmpGris.c . Here is my main file: #include<stdio.h> #include<stdlib.h> #include "myBmpGris.h" int main(){ char * image_name = "image_carre.bmp"; BmpImg image = readBmpImage(image_name); return 0; I compile by using ggc main.c and I get this error message : Undefined symbols for architecture x86_64: "

static library convert to a shared lib symbols are hidden?

余生颓废 提交于 2020-01-06 04:32:11
问题 I am trying to link v8's static library to a shared library using the following cmake command add_library(v8jni SHARED ${THIRDPARTY_LIB_PATH}/shared/v8jni.cpp) target_link_libraries(v8jni log -Wl,--whole-archive v8_inspector v8_base v8_snapshot v8_libplatform v8_libsampler v8_libbase -Wl,--no-whole-archive) libv8jni.so is generated successfully. But it's useless because all the v8 function are marked as local. nm -C libv8_base.a | grep v8::HandleScope 00000000 T v8::HandleScope::Initialize(v8

linking with static library in C

隐身守侯 提交于 2020-01-06 04:26:24
问题 Hi I'm a beginner in C and Linking, I was reading a book that has a question in linking with static library: Let a and b denote object modules or static libraries in the current directory, and let a→b denote that a depends on b, in the sense that b defines a symbol that is referenced by a. For each of the following scenarios, show the minimal command line (i.e., one with the least number of object file and library arguments) that will allow the static linker to resolve all symbol references:

Why do I get “unresolved external symbol” errors when using templates? [duplicate]

牧云@^-^@ 提交于 2020-01-05 19:41:41
问题 This question already has answers here : Why can templates only be implemented in the header file? (16 answers) Closed 5 years ago . When I write C++ code for a class using templates and split the code between a source (CPP) file and a header (H) file, I get a whole lot of "unresolved external symbol" errors when it comes to linking the final executible, despite the object file being correctly built and included in the linking. What's happening here, and how can I fix it? 回答1: Templated

“libgcc_s_sjlj-1.dll” is missing

ε祈祈猫儿з 提交于 2020-01-05 13:08:49
问题 I am trying to run my first SFML application. I can run it via Code Blocks environment, but I can't run it through the Explorer - an error appears that says: "libgcc_s_sjlj-1.dll is missing". I added these lines to my linker options: -static -static-libgcc -static-libstdc++ However, after trying to compile it, I see an error in the build log: mingw32-g++.exe: error: unrecognized command line option '-static-libstdc++' How can I fix it? My GCC version is 4.7.1 TDM-1 回答1: GCC 4.7.1 is a rather

How do I get make to figure out the correct dependencies to link in the correct downstream object files?

你离开我真会死。 提交于 2020-01-05 09:14:06
问题 I'm going to use a small example for reference. Consider a project with: inner_definitions.o : inner_definitions.cpp inner_definitions.h gcc $^ -o $@ inner_class_1.o : inner_class_1.cpp inner_class_1.h inner_definitions.h gcc $^ -o $@ inner_class_2.o : inner_class_2.cpp inner_class_2.h inner_definitions.h gcc $^ -o $@ outer_class.o : outer_class.cpp outer_class.h inner_class_1.h inner_class_2.h gcc $^ -o $@ executable.o : executable.cpp executable.h outer_class.h gcc $^ -o $@ executable : __

Linking LAPACK/BLAS libraries

ぐ巨炮叔叔 提交于 2020-01-05 08:32:20
问题 Background: I am working on a project written in a mix of C and Fortran 77 and now need to link the LAPACK/BLAS libraries to the project (all in a Linux environment). The LAPACK in question is version 3.2.1 (including BLAS) from netlib.org. The libraries were compiled using the top level Makefile (make lapacklib and make blaslib). Problem: During linking, error messages claimed that certain (not all) BLAS-routines called from LAPACK-routines were undefined. This gave me some headache but the

Linking LAPACK/BLAS libraries

北城以北 提交于 2020-01-05 08:32:13
问题 Background: I am working on a project written in a mix of C and Fortran 77 and now need to link the LAPACK/BLAS libraries to the project (all in a Linux environment). The LAPACK in question is version 3.2.1 (including BLAS) from netlib.org. The libraries were compiled using the top level Makefile (make lapacklib and make blaslib). Problem: During linking, error messages claimed that certain (not all) BLAS-routines called from LAPACK-routines were undefined. This gave me some headache but the

Static libraries and JNI

那年仲夏 提交于 2020-01-05 06:53:14
问题 I have created a header file and a corresponding .c file full of functions I would like to use with a java program. I created a JNI header file using javah. I'm using gcc to compile my header file. How can I link my regular c object file with my JNI static library to get a static library that utilizes my C library? I'm using gcc to compile. Here's an example of what I'm asking: lib.h lib.c JNITest.h JNITest.c (uses lib.h functions) 回答1: You might try looking at this http://java.sun.com