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

Linker warnings on macOS #1172

Closed
hmueller01 opened this issue Sep 30, 2024 · 12 comments
Closed

Linker warnings on macOS #1172

hmueller01 opened this issue Sep 30, 2024 · 12 comments

Comments

@hmueller01
Copy link
Contributor

During compilation of the plugins I get these warnings:

[ 85%] Linking CXX shared library ../libpaintPlugin.dylib
ld: warning: ignoring duplicate libraries: '-lc++'
ld: warning: search path '.../nomacs.hmueller01/build/libs' not found

There is no libs folder within build. So the warning is correct. Is it created at Linux or Windows?
Otherwise
${NOMACS_BUILD_DIRECTORY}/libs
at
https://github.com/novomesk/nomacs-plugins/blob/18861dc71c015006bfc551090a30e96b4fa37c78/CompositePlugin/CMakeLists.txt#L52
could be removed ...

I didn't find the reason for the duplicate libraries: '-lc++' yet. Is it on other platforms as well?

@scrubbbbs
Copy link
Collaborator

The lib folder is not on other platforms (864bb5b). I'm not seeing this on MacOS 12.7.6 / clang 14 / cmake 3.30.2. I am building out of tree in ~/tmp/build.nomacs like so:

cmake -DENABLE_QUAZIP=ON ~/src/nomacs/ImageLounge

@hmueller01
Copy link
Contributor Author

Ok,
nomacs.hmueller01/build> cmake -D QT_VERSION_MAJOR=6 -D ENABLE_QUAZIP=ON --install-prefix /Applications ../ImageLounge/
does not compile on my system (macOS Sonoma 14.7.1 / clang 15 / cmake 3.30.5)

...
[ 37%] Building CXX object CMakeFiles/nomacsCore-3.19.1.dir/qrc_nomacs.cpp.o
[ 38%] Building CXX object CMakeFiles/nomacsCore-3.19.1.dir/3rdparty/libqpsd/qpsdhandler.cpp.o
[ 39%] Building CXX object CMakeFiles/nomacsCore-3.19.1.dir/3rdparty/libqpsd/qpsdhandler_p.cpp.o
[ 40%] Building CXX object CMakeFiles/nomacsCore-3.19.1.dir/3rdparty/libqpsd/qpsdplugin.cpp.o
make[2]: *** No rule to make target `/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.sdk/usr/lib/libbz2.tbd', needed by `libnomacsCore-3.19.1.dylib'.  Stop.

(don't know why it tries to link libbz2.tbd in MacOSX13.sdk which must be MacOSX14.sdk on my system ...)

@scrubbbbs
Copy link
Collaborator

scrubbbbs commented Nov 18, 2024

(don't know why it tries to link libbz2.tbd in MacOSX13.sdk which must be MacOSX14.sdk on my system ...)

Well, you can have as many SDK versions as you want installed. homebrew might not be compatible with v14 yet.

"libbz2" looks like the bzip2 compression library. Perhaps this can be overridden with a homebrew package.

If this doesn't help, I would investigate this in homebrew support/forums, this type of error it would affect all sorts of applications (the name of the library might differ, for example "libz.tbd" is probably more common that libbz2.tbd).

As a last resort you may want to do a clean reinstall of latest homebrew and/or xcode/devtools. I don't know how possible it is to fully remove everything these days, but there used to be a script that would do it provided by Apple, I would recommend doing that first before the reinstall.

@hmueller01
Copy link
Contributor Author

I don't understand this.
I reinstalled pkg-config brew reinstall pkg-config like suggested here. No change.

I added

	if(USE_SYSTEM_QUAZIP)
		find_package(BZip2 REQUIRED)

to Mac.cmake and get

-- Found BZip2: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.1.sdk/usr/lib/libbz2.tbd (found version "1.0.8")
-- Looking for BZ2_bzCompressInit
-- Looking for BZ2_bzCompressInit - found

at the right location. But still the cmake likes to link libbz2.tbd (Considering target) from MacOSX14.sdk while libz.tbd is correct. This is frustrating ...

...
     Looking for an implicit rule for `/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.1.sdk/usr/lib/libz.tbd'.
     No implicit rule found for `/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.1.sdk/usr/lib/libz.tbd'.
     Finished prerequisites of target file `/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.1.sdk/usr/lib/libz.tbd'.
    No need to remake target `/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.1.sdk/usr/lib/libz.tbd'.
    Considering target file `/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.sdk/usr/lib/libbz2.tbd'.
     File `/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.sdk/usr/lib/libbz2.tbd' does not exist.
     Looking for an implicit rule for `/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.sdk/usr/lib/libbz2.tbd'.
     No implicit rule found for `/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.sdk/usr/lib/libbz2.tbd'.
     Finished prerequisites of target file `/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.sdk/usr/lib/libbz2.tbd'.
    Must remake target `/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.sdk/usr/lib/libbz2.tbd'.
make[2]: *** No rule to make target `/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.sdk/usr/lib/libbz2.tbd', needed by `libnomacsCore-3.19.1.dylib'.  Stop.

@scrubbbbs
Copy link
Collaborator

But still the cmake likes to link libbz2.tbd (Considering target) from MacOSX14.sdk

Maybe the cmake log has clues. Also in case you forgot, make sure to remove Cmakecache etc before re-running cmake (I just do git clean -dfx usually...note this will remove unstaged files as well)...

@hmueller01
Copy link
Contributor Author

Yeah, tried this all. Looks like the system (brew) quazip is somehow broken. So tried to rebuild from 3rd-party quazip (-D USE_SYSTEM_QUAZIP=OFF) with quite a lot of new trouble. Fixed them all in #1195.

But this does not relate to my original issue

[ 85%] Linking CXX shared library ../libpaintPlugin.dylib
ld: warning: ignoring duplicate libraries: '-lc++'
ld: warning: search path '.../nomacs.hmueller01/build/libs' not found

which is still there and IMHO shouldn't ...

@scrubbbbs scrubbbbs reopened this Nov 25, 2024
@hmueller01
Copy link
Contributor Author

ld: warning: search path '.../nomacs.hmueller01/build/libs' not found
could be avoided if we set
set_target_properties(${DLL_CORE_NAME} PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/libs)
in MacBuildTarget.cmake. It does have no other impact in my tests.
@scrubbbbs What do you think? Should I make a PR that you can test it as well?

@scrubbbbs
Copy link
Collaborator

Sure, lets do a PR. On a related topic, do you have any interest in fixing the build to make a portable binary/dmg possible?

@hmueller01
Copy link
Contributor Author

I found something ...
https://github.com/orgs/Homebrew/discussions/4794
Can be ignored by linker flag -no_warn_duplicate_libraries

@hmueller01
Copy link
Contributor Author

hmueller01 commented Nov 30, 2024

On a related topic, do you have any interest in fixing the build to make a portable binary/dmg possible?

What do you mean with "portable". I thought macdeployqt will do that job. Problem is also, how to test this ...

@scrubbbbs
Copy link
Collaborator

By portable I just mean the dmg can be published and work as expected (at least on the target OS/CPU). The last time I checked this was not working. I don't know if macdeployqt is at fault or we're doing it wrong.

To test it, monitor every dylib that is loaded, and make sure none come from /usr/local. I know there are environment variables to get this information, or maybe the debugger or some other tool if you prefer.

To double-check, maybe rename /usr/local temporarily, copy the .app from the .dmg to different locations.

@scrubbbbs
Copy link
Collaborator

Closing this issue as solved and open new issue for portable os x .dmg file.

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