Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues compiling shared library #26

Open
FSund opened this issue Aug 22, 2018 · 3 comments
Open

Issues compiling shared library #26

FSund opened this issue Aug 22, 2018 · 3 comments

Comments

@FSund
Copy link

FSund commented Aug 22, 2018

I'm trying to compile a shared library version of SuperLU. I'm using the following cmake command from the build directory

cmake -G'MSYS Makefiles' -Denable_blaslib=OFF -DCMAKE_INSTALL_PREFIX="C:/msys64/mingw64/" -DBUILD_SHARED_LIBS=TRUE ..

Running make works until it reaches Linking C shared library libmatgen.dll, where I get a lot of undefined reference to [...]-errors

[...]
[ 90%] Linking C shared library libmatgen.dll
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/matgen.dir/objects.a(slatm1.c.obj):slatm1.c:(.text+0x15d): undefined reference to `input_error'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/matgen.dir/objects.a(slatb4.c.obj):slatb4.c:(.text+0x38): undefined reference to `smach'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/matgen.dir/objects.a(slatb4.c.obj):slatb4.c:(.text+0x87): undefined reference to `smach'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/matgen.dir/objects.a(slartg.c.obj):slartg.c:(.text+0x3c): undefined reference to `smach'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/matgen.dir/objects.a(slartg.c.obj):slartg.c:(.text+0x52): undefined reference to `smach'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/matgen.dir/objects.a(slartg.c.obj):slartg.c:(.text+0x68): undefined reference to `smach'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/matgen.dir/objects.a(slartg.c.obj):slartg.c:(.text+0x9c): more undefined references to `smach' follow
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/matgen.dir/objects.a(slatms.c.obj):slatms.c:(.text+0x776): undefined reference to `input_error'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/matgen.dir/objects.a(slatms.c.obj):slatms.c:(.text+0xa83): undefined reference to `sscal_'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/matgen.dir/objects.a(slatms.c.obj):slatms.c:(.text+0xbdd): undefined reference to `scopy_'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/matgen.dir/objects.a(slatms.c.obj):slatms.c:(.text+0xca7): undefined reference to `scopy_'
[...]

I think this is some kind of linking error related to BLAS, but I haven't been able to figure it out. Any ideas?

EDIT: Compiling the static version seems to work fine, but then I get undefined reference to [...]-errors when trying to compile any program, for example EXAMPLES/superlu.c.

Using the internal BLAS instead of the installed version (cmake -G'MSYS Makefiles' -Denable_blaslib=ON -DCMAKE_INSTALL_PREFIX="C:/msys64/mingw64/" -DBUILD_SHARED_LIBS=TRUE ..) gives me the same errors, but at a different stage in the compilation

[...]
[ 16%] Building C object CBLAS/CMakeFiles/blas.dir/zher2.c.obj
[ 16%] Linking C shared library libblas.dll
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/blas.dir/objects.a(sgemv.c.obj):sgemv.c:(.text+0x117): undefined reference to `input_error'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/blas.dir/objects.a(ssymv.c.obj):ssymv.c:(.text+0xe5): undefined reference to `input_error'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/blas.dir/objects.a(strsv.c.obj):strsv.c:(.text+0x179): undefined reference to `input_error'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/blas.dir/objects.a(sger.c.obj):sger.c:(.text+0xb7): undefined reference to `input_error'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/blas.dir/objects.a(ssyr2.c.obj):ssyr2.c:(.text+0xe5): undefined reference to `input_error'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/blas.dir/objects.a(dgemv.c.obj):dgemv.c:(.text+0x117): more undefined references to `input_error' follow
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/blas.dir/objects.a(icamax.c.obj):icamax.c:(.text+0x7f): undefined reference to `r_imag'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/blas.dir/objects.a(icamax.c.obj):icamax.c:(.text+0x152): undefined reference to `r_imag'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/blas.dir/objects.a(icamax.c.obj):icamax.c:(.text+0x218): undefined reference to `r_imag'
[...]
@xiaoyeli
Copy link
Owner

xiaoyeli commented Aug 22, 2018 via email

@FSund
Copy link
Author

FSund commented Aug 24, 2018

Yes, I managed to get static linking to work in the end.

The issues might be related to Windows, but I am not sure. There is a comment on stack overflow suggesting using the options

-Wl,--out-implib,libexample_dll.a

to the linker to generate the import library libexample_dll.a. I have not tried this yet, since I am not sure how to do this when using CMake. Anyway, the static version works for me, so I will just use that.

@xiaoyeli
Copy link
Owner

xiaoyeli commented Aug 24, 2018 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants