libmir / mir-random

Advanced Random Number Generators
http://mir-random.libmir.org/
32 stars 15 forks source link

Compiling mir-glas and gsl together as a dependency results in error. #22

Closed prasunanand closed 7 years ago

prasunanand commented 7 years ago

I am working on a software for mixed-modelling. Currently, I have been using BLAS' gemm routine and would like to switch to mir-glas. However, gsl library doesn't go well with mir-glas.

Here is a sample program that can be used to reproduce the errors. gemm_example.

dub.json => link

If I remove, gsl from dependencies and libs in dub.json, the program compiles without any errors.

dub build --compiler=ldmd2 --parallel --force -v results in

https://gist.github.com/prasunanand/2bfd4b12e5fe43360bf0a0a90369af56

Other info

prasun@devUbuntu:~/dev/temp/gemm$ nm ~/.dub/packages/mir-cpuid-0.4.2/mir-cpuid/libmir-cpuid.a | grep cpuid_init
0000000000000000 T cpuid_init
prasun@devUbuntu:~/dev/temp/gemm$ nm ~/.dub/packages/mir-cpuid-0.4.2/mir-cpuid/libmir-cpuid.a | grep cpuid_dCache
0000000000000000 T cpuid_dCache
prasun@devUbuntu:~/dev/temp/gemm$ nm ~/.dub/packages/mir-cpuid-0.4.2/mir-cpuid/libmir-cpuid.a | grep cpuid_uCache
0000000000000000 T cpuid_uCache
prasun@devUbuntu:~/dev/temp/gemm$ ldmd2 -v
LDC - the LLVM D compiler (1.1.0):
  based on DMD v2.071.2 and LLVM 3.7.1
  built with LDC - the LLVM D compiler (0.17.1)
  Default target: x86_64-unknown-linux-gnu
  Host CPU: haswell
  http://dlang.org - http://wiki.dlang.org/LDC
...
prasunanand commented 7 years ago

The order of parameters is important to build the final executable. Changed

ldmd2 -of.dub/build/application-debug-linux.posix-x86_64-ldc_2071-6074926C76AB19CD776BAF78A8198391/gemm .dub/build/application-debug-linux.posix-x86_64-ldc_2071-6074926C76AB19CD776BAF78A8198391/gemm.o ../../../.dub/packages/mir-cpuid-0.4.2/mir-cpuid/.dub/build/library-debug-linux.posix-x86_64-ldc_2071-86B508216A4635809366D4F6A849D4A8/libmir-cpuid.a ../../../.dub/packages/mir-algorithm-0.0.30/mir-algorithm/.dub/build/library-debug-linux.posix-x86_64-ldc_2071-E4991B8128FC4747A767EA630113C462/libmir-algorithm.a ../../../.dub/packages/mir-internal-0.0.2/mir-internal/.dub/build/library-debug-linux.posix-x86_64-ldc_2071-B3B4694625705B637CB91780B7EF9921/libmir-internal.a -L--no-as-needed -L-L/home/prasun/.dub/packages/mir-glas-0.1.1/mir-glas/ -L-L/home/prasun/.dub/packages/mir-cpuid-0.4.2/mir-cpuid/ -L-L/home/prasun/.dub/packages/mir-internal-0.0.2/mir-internal/ -L-lgsl -L-lgslcblas -L-lm -L-lmir-cpuid -L-lmir-glas -L-lgslcblas -g

to

ldmd2 -of.dub/build/application-debug-linux.posix-x86_64-ldc_2071-6074926C76AB19CD776BAF78A8198391/gemm .dub/build/application-debug-linux.posix-x86_64-ldc_2071-6074926C76AB19CD776BAF78A8198391/gemm.o ../../../.dub/packages/mir-cpuid-0.4.2/mir-cpuid/.dub/build/library-debug-linux.posix-x86_64-ldc_2071-86B508216A4635809366D4F6A849D4A8/libmir-cpuid.a ../../../.dub/packages/mir-algorithm-0.0.30/mir-algorithm/.dub/build/library-debug-linux.posix-x86_64-ldc_2071-E4991B8128FC4747A767EA630113C462/libmir-algorithm.a ../../../.dub/packages/mir-internal-0.0.2/mir-internal/.dub/build/library-debug-linux.posix-x86_64-ldc_2071-B3B4694625705B637CB91780B7EF9921/libmir-internal.a -L--no-as-needed -L-L/home/prasun/.dub/packages/mir-glas-0.1.1/mir-glas/ -L-L/home/prasun/.dub/packages/mir-cpuid-0.4.2/mir-cpuid/ -L-L/home/prasun/.dub/packages/mir-internal-0.0.2/mir-internal/ -L-lm -L-lmir-glas -L-lmir-cpuid -L-lgsl -L-lgslcblas -g

and it works.

prasunanand commented 7 years ago

-L-lmir-glas should be followed by -L-lmir-cpuid