- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you for the details on your build environment.
I found a simple change to the ifort command line to build the dynamic lib. Use -Wl,-flat_namespace instead of -Wl,-single_module
$ ifort -dynamiclib -o lib.dylib lib.f90 -Wl,-flat_namespace
$ ifort -c -o lib.o lib.f90
$ ar rc lib.a lib.o
$ ifort -c -o prog.o prog.f90
$ ifort -o together prog.f90 lib.f90
$ ifort -o static prog.f90 lib.a
$ ifort -o dylib prog.o lib.dylib
$ ./together
3
$ ./static
3
$ ./dylib
3
I verified on:
- Lion 10.7+Xcode 4.1+ ifort 12.0.5.209 Build 20110719
- Snow Leopard 10.6 + Xcode 3.2 + ifort 12.0.3.167 Build 20110309
- Leopard 10.5 + Xcode 3.1.4 + ifort Version 11.1.088 Build 20100401
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This seems related to the earlier issues with COMMON discussedhere. I will try your test case and update soon.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm using Lion, XCode 4.2.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you for the details on your build environment.
I found a simple change to the ifort command line to build the dynamic lib. Use -Wl,-flat_namespace instead of -Wl,-single_module
$ ifort -dynamiclib -o lib.dylib lib.f90 -Wl,-flat_namespace
$ ifort -c -o lib.o lib.f90
$ ar rc lib.a lib.o
$ ifort -c -o prog.o prog.f90
$ ifort -o together prog.f90 lib.f90
$ ifort -o static prog.f90 lib.a
$ ifort -o dylib prog.o lib.dylib
$ ./together
3
$ ./static
3
$ ./dylib
3
I verified on:
- Lion 10.7+Xcode 4.1+ ifort 12.0.5.209 Build 20110719
- Snow Leopard 10.6 + Xcode 3.2 + ifort 12.0.3.167 Build 20110309
- Leopard 10.5 + Xcode 3.1.4 + ifort Version 11.1.088 Build 20100401
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
There's a better solution than that. Just use -Wl,-commons,use_dylibs for the final link and no need to use -Wl,flat_namespace.
$ ifort -c -o lib.o lib.f90
$ ar rc lib.a lib.o
$ ifort -c -o prog.o prog.f90
$ ifort -o together prog.f90 lib.f90
$ ifort -o static prog.f90 lib.a
$ ifort -o dylib prog.o lib.dylib -Wl,-commons,use_dylibs
$ ./together
3
$ ./static
3
$ ./dylib
3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
![](/skins/images/DC0E2679F7049B943291D1ED082A478E/responsive_peak/images/icon_anonymous_message.png)
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page