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

Mac OS X makes static linking difficult #245

Open
sobolevnrm opened this issue Sep 27, 2022 · 2 comments
Open

Mac OS X makes static linking difficult #245

sobolevnrm opened this issue Sep 27, 2022 · 2 comments

Comments

@sobolevnrm
Copy link
Member

    Unfortunately, this still seems to be an issue in the 3.4.1 release.
Performing C SOURCE FILE Test Intl_IS_BUILT_IN failed with the following output:
Change Dir: /tmp/apbs-20220926-39068-n0ircz/build/CMakeFiles/CMakeTmp

Run Build Command(s):/opt/homebrew/bin/gmake -f Makefile cmTC_799a3/fast && /opt/homebrew/bin/gmake  -f CMakeFiles/cmTC_799a3.dir/build.make CMakeFiles/cmTC_799a3.dir/build
gmake[1]: Entering directory '/private/tmp/apbs-20220926-39068-n0ircz/build/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_799a3.dir/src.c.o
/opt/homebrew/Library/Homebrew/shims/mac/super/gcc-12 -DIntl_IS_BUILT_IN  -fopenmp -fPIC  -arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk -o CMakeFiles/cmTC_799a3.dir/src.c.o -c /tmp/apbs-20220926-39068-n0ircz/build/CMakeFiles/CMakeTmp/src.c
Linking C executable cmTC_799a3
/opt/homebrew/Cellar/cmake/3.24.2/bin/cmake -E cmake_link_script CMakeFiles/cmTC_799a3.dir/link.txt --verbose=1
/opt/homebrew/Library/Homebrew/shims/mac/super/gcc-12 -fopenmp -fPIC  -arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk -Wl,-search_paths_first -Wl,-headerpad_max_install_names CMakeFiles/cmTC_799a3.dir/src.c.o -o cmTC_799a3 
Undefined symbols for architecture arm64:
  "_libintl_dcgettext", referenced from:
      _main in src.c.o
  "_libintl_dgettext", referenced from:
      _main in src.c.o
  "_libintl_gettext", referenced from:
      _main in src.c.o
ld: symbol(s) not found for architecture arm64
collect2: error: ld returned 1 exit status
gmake[1]: *** [CMakeFiles/cmTC_799a3.dir/build.make:99: cmTC_799a3] Error 1
gmake[1]: Leaving directory '/private/tmp/apbs-20220926-39068-n0ircz/build/CMakeFiles/CMakeTmp'
gmake: *** [Makefile:127: cmTC_799a3/fast] Error 2


Source file was:
#include <libintl.h>
int main(void) {
  gettext("");
  dgettext("", "");
  dcgettext("", "", 0);
  return 0;
}

Performing C SOURCE FILE Test Iconv_IS_BUILT_IN failed with the following output:
Change Dir: /tmp/apbs-20220926-39068-n0ircz/build/CMakeFiles/CMakeTmp

Run Build Command(s):/opt/homebrew/bin/gmake -f Makefile cmTC_a634d/fast && /opt/homebrew/bin/gmake  -f CMakeFiles/cmTC_a634d.dir/build.make CMakeFiles/cmTC_a634d.dir/build
gmake[1]: Entering directory '/private/tmp/apbs-20220926-39068-n0ircz/build/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_a634d.dir/src.c.o
/opt/homebrew/Library/Homebrew/shims/mac/super/gcc-12 -DIconv_IS_BUILT_IN  -fopenmp -fPIC  -arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk -o CMakeFiles/cmTC_a634d.dir/src.c.o -c /tmp/apbs-20220926-39068-n0ircz/build/CMakeFiles/CMakeTmp/src.c
Linking C executable cmTC_a634d
/opt/homebrew/Cellar/cmake/3.24.2/bin/cmake -E cmake_link_script CMakeFiles/cmTC_a634d.dir/link.txt --verbose=1
/opt/homebrew/Library/Homebrew/shims/mac/super/gcc-12 -fopenmp -fPIC  -arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk -Wl,-search_paths_first -Wl,-headerpad_max_install_names CMakeFiles/cmTC_a634d.dir/src.c.o -o cmTC_a634d 
Undefined symbols for architecture arm64:
  "_libiconv", referenced from:
      _main in src.c.o
  "_libiconv_close", referenced from:
      _main in src.c.o
  "_libiconv_open", referenced from:
      _main in src.c.o
ld: symbol(s) not found for architecture arm64
collect2: error: ld returned 1 exit status
gmake[1]: *** [CMakeFiles/cmTC_a634d.dir/build.make:99: cmTC_a634d] Error 1
gmake[1]: Leaving directory '/private/tmp/apbs-20220926-39068-n0ircz/build/CMakeFiles/CMakeTmp'
gmake: *** [Makefile:127: cmTC_a634d/fast] Error 2


Source file was:

      #include <stddef.h>
      #include <iconv.h>
      int main() {
        char *a, *b;
        size_t i, j;
        iconv_t ic;
        ic = iconv_open("to", "from");
        iconv(ic, &a, &i, &b, &j);
        iconv_close(ic);
      }

Incidentally, I also needed to pass -DBLA_VENDOR=OpenBLAS -DCMAKE_C_FLAGS=-fopenmp to CMake to get it this far, as well as making sure OpenMP is installed (despite -DENABLE_OPENMP=OFF).

Originally posted by @alexreg in #217 (comment)

@sobolevnrm
Copy link
Member Author

I do not own a Mac. Is anyone able to help with this issue?

Thank you!

@alexreg
Copy link

alexreg commented Sep 27, 2022

@sobolevnrm Thanks. Happy to test for you, if you want to suggest things or push potential fixes to a branch.

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