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

GSL Linking Problem For Piranha Setup #19

Open
reformist opened this issue Apr 9, 2024 · 3 comments
Open

GSL Linking Problem For Piranha Setup #19

reformist opened this issue Apr 9, 2024 · 3 comments

Comments

@reformist
Copy link

I'm having trouble running ./configure on the Mac 13.4 (22F66) Ventura system. After confirming GSL installment, I can't link GSL. I've tried xcode-select --install and ./configure CFLAGS="-I/opt/homebrew/Cellar/gsl/2.7.1/include" LDFLAGS="-L/opt/homebrew/Cellar/gsl/2.7.1/lib -lgsl -lgslcblas -lm"
I've also tried Xcode-select --install (which was recommended in this stack overflow answer: https://stackoverflow.com/questions/23905661/on-mac-g-clang-fails-to-search-usr-local-include-and-usr-local-lib-by-def) and just got the statement that command line tools are already installed

below is my error statement
checking for g++... g++
checking for C++ compiler default output file name... a.out
checking whether the C++ compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
checking whether we're compiling on Darwin/MacOS... yes
configure: no BAMTools headers directory specified
configure: no BAMTools library directory specified
checking for cos in -lm... yes
checking for cblas_dgemm in -lgslcblas... no
checking for gsl_blas_dgemm in -lgsl... no
checking for linking against gsl matrix... no
configure: error: could not find or link to GSL -- Piranha requires GSL and cannot be built without it. GSL can be downloaded from http://www.gnu.org/software/gsl/ -- please ensure GSL is correctly installed on your system

@andrewdavidsmith
Copy link

@reformist I'll try to help, but can't be 100% sure because I don't know if I have a machine that I can configure just like yours. First, I suggest to try and install a compiler using Homebrew (brew) if you can. It's very tricky to get recent versions of macOS to cooperate, and the compiler that comes with Xcode is unlikely to want to see GSL. From the other direction, you can try to get your current compiler to see GSL. But it might require CPPFLAGS instead of CFLAGS. The meaning of CPPFLAGS is for the preprocessor, which handles includes (and therefore -I). My guess would be that CFLAGS should be able to place the right things on the compile command, but that's going to depend on the internals of the ./configure script. One further thing to debug: when there is a failure like the one you see at the bottom of your output, there will usually be a log file in the same directory. The log file should have "error" somewhat close to the bottom, although it won't be exactly at the bottom. Near that, there should be a snippet of C or C++ code on lines that begin with the "|" (pipe) character. Just below or above that code snippet should be the compile command used to try and find GSL (here, -lgsl and -lgslcblas). This usually has much more information.

@reformist
Copy link
Author

Thank you for your quick response! I've tried CPPFLAGS and installed gcc with home-brew but still running into same problem. I tried the config.log hint and I got that there were files meant for macOS-arm64 but were being built for macOS-86x64. I then did arch -x86_64 brew install gsl to try and install the correct gsl, but still running into an error with this now:

configure:2576: checking for cos in -lm
configure:2611: g++ -o conftest -g -O2 -arch x86_64 conftest.cpp -lm >&5
configure:2618: $? = 0
configure:2639: result: yes
configure:2651: checking for cblas_dgemm in -lgslcblas
configure:2686: g++ -o conftest -g -O2 -arch x86_64 conftest.cpp -lgslcblas -lm >&5
ld: library not found for -lgslcblas
clang: error: linker command failed with exit code 1 (use -v to see invocation)
configure:2693: $? = 1
configure: failed program was:
| /* confdefs.h. /
| #define PACKAGE_NAME "Piranha"
| #define PACKAGE_TARNAME "piranha"
| #define PACKAGE_VERSION "version-1.2.1"
| #define PACKAGE_STRING "Piranha version-1.2.1"
| #define PACKAGE_BUGREPORT ""
| #define HAVE_LIBM 1
| /
end confdefs.h. /
|
| /
Override any GCC internal prototype to avoid an error.
| Use char because int might match the return type of a GCC
| builtin and then its argument prototype would still apply. */
| #ifdef __cplusplus
| extern "C"
| #endif
| char cblas_dgemm ();
| int
| main ()
| {
| return cblas_dgemm ();
| ;
| return 0;
| }
configure:2714: result: no
configure:2726: checking for gsl_blas_dgemm in -lgsl
configure:2761: g++ -o conftest -g -O2 -arch x86_64 conftest.cpp -lgsl -lm >&5
ld: library not found for -lgsl
clang: error: linker command failed with exit code 1 (use -v to see invocation)
configure:2768: $? = 1
configure: failed program was

@andrewdavidsmith
Copy link

andrewdavidsmith commented Apr 9, 2024

I'll share a cleaned-up version of that test code snippet that I just used. @reformist If you can't make this super-small test-case build, then the whole thing likely can't be built, so let's just start here. Code:

#ifdef __cplusplus
extern "C"
#endif
char cblas_dgemm ();
int
main ()
{
  return cblas_dgemm ();
  ;
  return 0;
}

I was able to build it using the compile command that is in the ./configure log you pasted (note: the binary isn't intended to run, just build):

sh-3.2$ g++ -o conftest -g -O2 -arch x86_64 conftest.cpp -lgslcblas -lm

I don't typically use the built-in g++ but I have it sill installed, so here's what I used for this test:

sh-3.2$ which g++
/usr/bin/g++
sh-3.2$ g++ --version
Apple clang version 15.0.0 (clang-1500.1.0.1.1)
Target: x86_64-apple-darwin23.4.0
Thread model: posix
InstalledDir: /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
sh-3.2$ 

The sh-3.2 is because I just started a new default shell to clear as much of my environment as I could. Here's what I have for GSL installed:

sh-3.2$ find /usr -name \*libgsl\*
find: /usr/sbin/authserver: Permission denied
/usr/local/lib/libgsl.dylib
/usr/local/lib/libgsl.27.dylib
/usr/local/lib/libgslcblas.a
/usr/local/lib/libgsl.a
/usr/local/lib/libgslcblas.0.dylib
/usr/local/lib/libgslcblas.dylib
/usr/local/Cellar/gsl/2.7.1/lib/libgsl.dylib
/usr/local/Cellar/gsl/2.7.1/lib/libgsl.27.dylib
/usr/local/Cellar/gsl/2.7.1/lib/libgslcblas.a
/usr/local/Cellar/gsl/2.7.1/lib/libgsl.a
/usr/local/Cellar/gsl/2.7.1/lib/libgslcblas.0.dylib
/usr/local/Cellar/gsl/2.7.1/lib/libgslcblas.dylib
sh-3.2$ find /Applications -name \*libgsl\*
sh-3.2$ 

I think they are just one set of files with symlinks. Here are environment variables I have set that might not be standard or the same as you have:

sh-3.2$ echo $PATH
/usr/local/bin:/usr/bin:/bin
sh-3.2$ echo $LD_LIBRARY_PATH
/usr/local/lib
sh-3.2$ echo $LIBRARY_PATH 
/usr/local/lib
sh-3.2$ echo $CPLUS_INCLUDE_PATH 
/usr/local/include

Hopefully this can help us make some progress.

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