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

Error on build using Mac OS #14

Closed
oltodo opened this issue Jan 29, 2019 · 23 comments
Closed

Error on build using Mac OS #14

oltodo opened this issue Jan 29, 2019 · 23 comments

Comments

@oltodo
Copy link

oltodo commented Jan 29, 2019

Hello,

I try to build your tool but I meet some troubles. After cloning your repo, I launched this two commands:

$ cmake .
$ make

An error appear on the second one:

Details
[...]
[ 31%] No patch step for 'QtCreator'
[ 36%] Performing update step for 'QtCreator'
[ 40%] Performing configure step for 'QtCreator'
-- The C compiler identification is AppleClang 10.0.0.10001145
-- The CXX compiler identification is AppleClang 10.0.0.10001145
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Error at CMakeLists.txt:39 (find_package):
By not providing "FindQt5Script.cmake" in CMAKE_MODULE_PATH this project
has asked CMake to find a package configuration file provided by
"Qt5Script", but CMake did not find one.

Could not find a package configuration file provided by "Qt5Script" with
any of the following names:

Qt5ScriptConfig.cmake
qt5script-config.cmake

Add the installation prefix of "Qt5Script" to CMAKE_PREFIX_PATH or set
"Qt5Script_DIR" to a directory containing one of the above files. If
"Qt5Script" provides a separate development package or SDK, be sure it has
been installed.

-- Configuring incomplete, errors occurred!
See also "/Users/nbazille/www/qmlfmt/QtCreator-prefix/src/QtCreator-build/CMakeFiles/CMakeOutput.log".
make[2]: *** [QtCreator-prefix/src/QtCreator-stamp/QtCreator-configure] Error 1
make[1]: *** [CMakeFiles/QtCreator.dir/all] Error 2
make: *** [all] Error 2


Environment:

$ sw_vers
ProductName:	Mac OS X
ProductVersion:	10.14.1
BuildVersion:	18B75
$ cmake --version
cmake version 3.10.2

CMake suite maintained and supported by Kitware (kitware.com/cmake).
$ make --version
GNU Make 3.81
Copyright (C) 2006  Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.

This program built for i386-apple-darwin11.3.0
@jesperhh
Copy link
Owner

Hi,

Thanks for reporting the issue, I don't have a Mac system here, but I recently accepted a pull request for removing Qt Script for some of the build process as it is now deprecated - can you try to remove the remaining references and retry the build?

In qmlfmt/QtCreator/CMakeLists.txt:
Delete find_package(Qt5Script REQUIRED)
and the two references to Qt5::Script

@oltodo
Copy link
Author

oltodo commented Jan 29, 2019

Thanks for answering!

I tried what you've suggested me. The previous error disappeared but I get a new one at the end:

[...]
[ 98%] Building CXX object CMakeFiles/qmljs.dir/src/libs/qmljs/qmljstypedescriptionreader.cpp.o
[ 99%] Building CXX object CMakeFiles/qmljs.dir/src/libs/qmljs/qmljsutils.cpp.o
[ 99%] Building CXX object CMakeFiles/qmljs.dir/src/libs/qmljs/qmljsvalueowner.cpp.o
[ 99%] Building CXX object CMakeFiles/qmljs.dir/src/libs/qmljs/qmljsviewercontext.cpp.o
[100%] Building CXX object CMakeFiles/qmljs.dir/qmljs_autogen/mocs_compilation.cpp.o
[100%] Linking CXX static library Release/libqmljs.a
[100%] Built target qmljs
[ 50%] No install step for 'QtCreator'
[ 54%] Completed 'QtCreator'
[ 54%] Built target QtCreator
Scanning dependencies of target qmlfmt_autogen
[ 59%] Automatic MOC for target qmlfmt
[ 59%] Built target qmlfmt_autogen
Scanning dependencies of target qmlfmt
[ 63%] Building CXX object CMakeFiles/qmlfmt.dir/main.cpp.o
[ 68%] Building CXX object CMakeFiles/qmlfmt.dir/qmlfmt.cpp.o
[ 72%] Building CXX object CMakeFiles/qmlfmt.dir/qmlfmt_autogen/mocs_compilation.cpp.o
[ 77%] Linking CXX executable qmlfmt
Undefined symbols for architecture x86_64:
  "Utils::Internal::filePathUrl(QUrl const&)", referenced from:
      Utils::isFileDrop(QMimeData const*, QList<Utils::DropSupport::FileSpec>*) in libutils.a(dropsupport.cpp.o)
  "Utils::Internal::normalizePathName(QString const&)", referenced from:
      Utils::FileUtils::normalizePathName(QString const&) in libutils.a(fileutils.cpp.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [qmlfmt] Error 1
make[1]: *** [CMakeFiles/qmlfmt.dir/all] Error 2
make: *** [all] Error 2

Sorry I'm not an expert about building C++ apps.

@jesperhh
Copy link
Owner

Hmm, could be a newer/older version of Qt that I have not tested with, what version are you using?
Can you try qmake -v in a terminal?

@oltodo
Copy link
Author

oltodo commented Jan 29, 2019

$ qmake -v
QMake version 3.0
Using Qt version 5.5.1 in /Applications/Qt/5.5/clang_64/lib

It uses the Qt 5.5.1 version. I can try with a 5.12 version.

@oltodo
Copy link
Author

oltodo commented Jan 29, 2019

Sorry, I used the wrong terminal, I was already using the 5.12 version:

$ qmake -v
QMake version 3.1
Using Qt version 5.12.0 in /Applications/Qt/5.12.0/clang_64/lib

@oltodo oltodo changed the title Error on build Error on build using Mac OS Jan 29, 2019
@jesperhh
Copy link
Owner

I can see that the build automation only builds with 5.10 at the moment, I will take a look at getting it working with Qt 5.12 this week- my guess is that is the reason it does not build.

@oltodo
Copy link
Author

oltodo commented Jan 29, 2019

Ok, I'm going to install the 5.10 version. I've just tested with the 5.5.1, but it doesn't work too.

@oltodo
Copy link
Author

oltodo commented Jan 29, 2019

Argh, not better with the 5.10.1 version, same error. 😞

@oltodo
Copy link
Author

oltodo commented Feb 1, 2019

The problem should come from this line:

new QmlJS::ModelManagerInterface();

@jesperhh
Copy link
Owner

jesperhh commented Feb 2, 2019

My guess is that this is just the first place that triggers the dependency for the reformatting library - if you remove that line it will just fail the next place that uses the reformatter.

I am working on setting up continuous integration for a clang build, I hope that will uncover what the issue is.

@jesperhh
Copy link
Owner

jesperhh commented Feb 3, 2019

I have created a new branch built on qt creator 4.8.1, can you try that one out?
https://github.com/jesperhh/qmlfmt/tree/submodulesetc

I have also set up a clang build on it, and it passes, so at least that is not the source of the issue.

@oltodo
Copy link
Author

oltodo commented Feb 4, 2019

I got an error on the cmake command:

CMake Error at qmljs/CMakeLists.txt:66 (list):
  list sub-command REMOVE_ITEM requires two or more arguments.

Do you know what it means?

@jesperhh
Copy link
Owner

jesperhh commented Feb 4, 2019 via email

@oltodo
Copy link
Author

oltodo commented Feb 4, 2019

Ok, thanks, I never use this.

@oltodo
Copy link
Author

oltodo commented Feb 4, 2019

Sorry, but still some errors:

[ 98%] Linking CXX executable qmlfmt
Undefined symbols for architecture x86_64:
  "Utils::Internal::filePathUrl(QUrl const&)", referenced from:
      Utils::isFileDrop(QMimeData const*, QList<Utils::DropSupport::FileSpec>*) in libutils.a(dropsupport.cpp.o)
  "Utils::Internal::normalizePathName(QString const&)", referenced from:
      Utils::FileUtils::normalizePathName(QString const&) in libutils.a(fileutils.cpp.o)
  "Utils::Internal::forceMacOSLightAquaApperance()", referenced from:
      Utils::setCreatorTheme(Utils::Theme*) in libutils.a(theme.cpp.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

@oltodo
Copy link
Author

oltodo commented Feb 4, 2019

If it can help:

$ clang -v
Apple LLVM version 10.0.0 (clang-1000.11.45.5)
Target: x86_64-apple-darwin18.2.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

@jesperhh
Copy link
Owner

jesperhh commented Feb 4, 2019

I think I found some of the issue at least - missing include of .mm files. Can you try again in the submodule branch?

..you need to rerun CMake configure as I have added some new files

..I updated it some more, missing mac specific frameworks

@oltodo
Copy link
Author

oltodo commented Feb 4, 2019

I still get this kind of errors but this time more 😞

[ 98%] Linking CXX executable qmlfmt
Undefined symbols for architecture x86_64:
  "_NSApp", referenced from:
      Utils::Internal::forceMacOSLightAquaApperance() in libutils.a(theme_mac.mm.o)
  "_NSAppearanceNameAqua", referenced from:
      Utils::Internal::forceMacOSLightAquaApperance() in libutils.a(theme_mac.mm.o)
  "_NSURLNameKey", referenced from:
      Utils::Internal::normalizePathName(QString const&) in libutils.a(fileutils_mac.mm.o)
  "_OBJC_CLASS_$_NSAppearance", referenced from:
      objc-class-ref in libutils.a(theme_mac.mm.o)
  "_OBJC_CLASS_$_NSURL", referenced from:
      objc-class-ref in libutils.a(fileutils_mac.mm.o)
  "_objc_autoreleasePoolPop", referenced from:
      Utils::Internal::filePathUrl(QUrl const&) in libutils.a(fileutils_mac.mm.o)
      Utils::Internal::normalizePathName(QString const&) in libutils.a(fileutils_mac.mm.o)
  "_objc_autoreleasePoolPush", referenced from:
      Utils::Internal::filePathUrl(QUrl const&) in libutils.a(fileutils_mac.mm.o)
      Utils::Internal::normalizePathName(QString const&) in libutils.a(fileutils_mac.mm.o)
  "_objc_msgSend", referenced from:
      Utils::Internal::filePathUrl(QUrl const&) in libutils.a(fileutils_mac.mm.o)
      Utils::Internal::normalizePathName(QString const&) in libutils.a(fileutils_mac.mm.o)
      Utils::Internal::forceMacOSLightAquaApperance() in libutils.a(theme_mac.mm.o)
ld: symbol(s) not found for architecture x86_64

@jesperhh
Copy link
Owner

jesperhh commented Feb 4, 2019

And you have the version where I added:

if (APPLE)
	find_library(AppKit AppKit)
	find_library(Foundation Foundation)
	
	target_link_libraries(utils ${AppKit} ${Foundation})
endif()

In qmljs/QMakeLists.txt?

@oltodo
Copy link
Author

oltodo commented Feb 5, 2019

Sorry I tried with the previous commit. I got this error on cmake:

CMake Error at qmljs/CMakeLists.txt:89 (target_link_libraries):
  The keyword signature for target_link_libraries has already been used with
  the target "utils".  All uses of target_link_libraries with a target must
  be either all-keyword or all-plain.

  The uses of the keyword signature are here:

   * qmljs/CMakeLists.txt:79 (target_link_libraries)

@oltodo
Copy link
Author

oltodo commented Feb 5, 2019

Good news, I make some changes and it finally worked!

-target_link_libraries(utils PRIVATE Qt5::Widgets Qt5::Network Qt5::Concurrent Qt5::Qml)
+# target_link_libraries(utils PRIVATE Qt5::Widgets Qt5::Network Qt5::Concurrent Qt5::Qml)

if(WIN32)
	target_link_libraries(utils PRIVATE user32 iphlpapi ws2_32 shell32)
endif()

if (APPLE)
	find_library(AppKit AppKit)
	find_library(Foundation Foundation)
	
-	target_link_libraries(utils ${AppKit} ${Foundation})
+	# target_link_libraries(utils ${AppKit} ${Foundation})
+	target_link_libraries(utils PRIVATE Qt5::Widgets Qt5::Network Qt5::Concurrent Qt5::Qml ${AppKit} ${Foundation})
endif()

@oltodo oltodo closed this as completed Feb 5, 2019
@oltodo oltodo reopened this Feb 5, 2019
@jesperhh
Copy link
Owner

jesperhh commented Feb 5, 2019

Great! I think it would be enough to just add "PRIVATE" to the line:

target_link_libraries(utils ${AppKit} ${Foundation})

So I will integrate that in this changeset

@oltodo
Copy link
Author

oltodo commented Feb 6, 2019

Thanks @jesperhh for investigating and fixing!

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