I'm trying to build an Xcode project with GNUStep-make. Right now the project is very small (3 classes) however it will grow to hundreds of classes over the coming weeks so I'm trying to get everything figured out and well-organised now.
Xcode creates a ProjectName_Prefix.pch file which is a header that: a) get precompiled and b) is prefixed to every file in my project; at least if I understand correctly.
Now, how do I tell GNUStep-make what to do with this file when it builds? I've added it to the XXX_PRECOMPILED_HEADERS variable.
Cioccolata_OBJC_PRECOMPILED_HEADERS = Cioccolata_Prefix.pch
With this in place the build fails with the error:
Making all for framework Cioccolata...
make[1]: *** No rule to make target `/Users/chris/Projects/Mac/Cioccolata/build/GNUStep/obj/PrecompiledHeaders/ObjC/Cioccolata_Prefix.pch', needed by `internal-precompile-headers'. Stop.
make: *** [Cioccolata.all.framework.variables] Error 2
I've also got the following in my makefile:
ADDITIONAL_OBJC_FLAGS += -include Cioccolata_Prefix.pch -Winvalid-pch
I'm not sure what I've done wrong here. I basically have tried to follow the GNUStep documentation for precompiled headers.
None of my project's source files expressly include the Foundation framework since this header does that.
Thanks for pointing our attention to this problem and for your patch! :-)
This is now fixed on gnustep-make trunk, and so will be fixed in gnustep-make 2.4.0 once released.
Nicola Pero (gnustep-make)
Related
I'm a *nix user, installing LLVM is easy for me, just download the precompiled file, set LLVM_DIR, and you're done. But I'm having a lot of problems with Windows ...
I downloaded LLVM-<version>-win64.exe from the GitHub release, but I can't find LLVMConfig.cmake file. Then I tried to compile LLVM from the source following this documentation.
When I started compiling my own project, I got this error:
'C:/<...>/Debug/libLLVMSupport.lib', needed by '<...>.exe', missing and no known rule to make it
I guess maybe I'm missing some compile options. but I can't find the documentation for LLVM_ENABLE_PROJECTS or BUILD_SHARED_LIBS, not even a list of component names.
I tried to add -DBUILD_SHARED_LIBS=ON but CMake told me BUILD_SHARED_LIBS option is not supported on Windows.
I've been using Eclipse for a while now for java development and it is seamless. I considered using eclipse for C development also. I installed C/C++ IDE CDT 9.9 addon from the marketplace. I now can create a Makefile project and develop code. But, I'm not able to debug code. After some research, I understood that the native debugger CDT is integrated with, GDB is no longer shipped with macOS. So, at this point, I understood that I have two solutions:
Install GDB and everything works normally.
Install LLDB addon for Eclipse available at the marketplace and everything works normally.
I went on installing LLDB addon for Eclipse and when tried to debug, it showed me:
I checked it in the terminal and I found out that lldb is available and lldb-mi is not available. I googled it and found lldb-mi. To install lldb-mi as shown on the Github page, I needed to install CMake. When I try to generate build files for lldb-mi using CMake, it showed me:
After seeing this message, I thought I may need to install LLVM. I googled and found two ways:
Install from Homebrew
Compile and build from source code and install from it
I chose to go and compile the source code and install it. I downloaded llvm-9.0.0.src and generated build as instructed here. It took almost 2 hours and gave this error:
Now, as I understand it, I just generated build files(Makefiles) and compiled the LLVM source code. It's 19GB in size now. Should I go ahead and install it? or have I misinterpreted anything and did anything wrong?
As #Tsyvarev pointed out, using sudo, llvm got installed successfully. Now, lldb-mi needs to be installed. When I go back and cmake ., it's showing me this error:
Karthiks-MacBook-Pro:lldb-mi-master karthik$ sudo cmake .
-- Found LLVM 9.0.0
-- Using LLVMConfig.cmake in: /usr/local/lib/cmake/llvm
-- Building with -fPIC
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
lib_lldb
linked by target "lldb-mi" in directory /Users/karthik/Downloads/lldb-mi-master/src
-- Configuring incomplete, errors occurred!
See also "/Users/karthik/Downloads/lldb-mi-master/CMakeFiles/CMakeOutput.log".
As #squareskittles pointed, I understood that lldb-mi requires lib_lldb for cmake to generate build files. I did:
$git clone https://github.com/lldb-tools/lldb-mi
$cd lldb-mi
$mkdir build
$cmake -DCMAKE_PREFIX_PATH=path/to/llvm/root/tree -S . -B build/
CMake should generate all the build files into lldb-mi/build/. It is successful.
$cd build
$make
make should compile the code. It produced:
Karthiks-MacBook-Pro:lldb-mi karthik$ cd build
Karthiks-MacBook-Pro:build karthik$ make
[ 1%] Building CXX object src/CMakeFiles/lldb-mi.dir/MICmdArgValListBase.cpp.o
In file included from /Users/karthik/buildspace/lldb-mi/src/MICmdArgValListBase.cpp:10:
/Users/karthik/buildspace/lldb-mi/src/MICmdArgValListBase.h:40:69: error: a space is required between consecutive right
angle brackets (use '> >')
: public CMICmdArgValBaseTemplate<std::vector<CMICmdArgValBase *>> {
^~
> >
1 error generated.
make[2]: *** [src/CMakeFiles/lldb-mi.dir/MICmdArgValListBase.cpp.o] Error 1
make[1]: *** [src/CMakeFiles/lldb-mi.dir/all] Error 2
make: *** [all] Error 2
Karthiks-MacBook-Pro:build karthik$
I put space between those > >, but there are still a lot of errors in the code.
I presume there are errors in the lldb-mi repository itself.
Can anyone tell me what I should be doing now?
Thanks in advance!
The lldb-mi not longer present from Xcode 11.x, but lldb and LLDB.Framework already included in the Xcode.
Use the lldb-mi that comes bundled with previous versions of XCode( 10.x) , the location is ‘Xcode.app/Contents/Developer/usr/bin/lldb-mi’, copy it to the same location of current version XCode.
And, in Eclipse, change the lldb command location.
Fine!
I am currently having a bear of a time trying to compile a moderate sized library with a brand new toolchain, Assimp on Xcode6 with the new iOS 8.0 SDK.
Bundled with the project are various scripts and Xcode projects that have configurations for building on iOS, but unfortunately none of them work out of the box.
So far the farthest I have gotten is by using a build script which uses the cmake "Unix Makefiles" method to assemble static libs. Other methods would include using cmake to generate Xcode projects to use to build. I tried that also to no avail, and neither did the Xcodeproject that comes with the project in the repository (which I later learned was marked deprecated in one of the readme files).
Okay, so with this "Unix Makefiles" cmake script I have been able to generate some of the static libs (after manually forcing static lib generation inside the main CMakeLists.txt), but when it went on to build for i386 and x86_64 architectures for iPhoneSimulator it kept pulling in the headers for iOS which caused a torrent of compiler errors.
Luckily I followed a hunch and found assimp/code/CMakeFiles/assimp.dir/flags.make which is one of the cmake-generated files, and lo and behold, the entire cflags was in here, and once I removed the rogue header include path, the make call finally succeeds and I have my iPhoneSimulator static lib!
Okay so the question that I have is basically where do I get started when debugging these frustrating cmake problems. My relationship with cmake has always been a strained one because none of cmake's complexity and design principles ever made sense to me, and very infrequent are the times when cmake builds work for me out of the box... it is always something that almost works but then I have to spend hours debugging with make VERBOSE=1 and then haphazardly poking at generated files, which are of course all marked with warnings to not edit them as they are generated files.
I realize that some of the variables here are perhaps relevant to my troubles. But it isn't clear to me how I can debug these variables. Where do I go to print out these variables so that I can find which variable contains erroneous values? For example, in this most recent situation I had a -I flag that was cropping up in the wrong place. Luckily I was able to find a file that contained it using various large-hammer methods that involve grep but I am not close to actually fixing the build configuration to make the process any less painful in the future.
For complex CMakeLists.txt files I have found the variable_watch command can sometimes be useful (documentation here). It doesn't make it easy, but gives you another level of information.
I've got a project which is going to be a c++ library for use in other c++ code.
It's made of a single .cpp implementation file and a single .h file for the interface. Normally I'd just compile the .cpp implementation file and then link it with other files with g++ in something like Ubuntu, however in Xcode 5 there's the Option Product>Build, Product>Build for... Running,testing, profiling and then there are the Perform action options to compile analyse, pre-process and assemble individual files. So with Xcode 5 how exactly do I complete my c++ library project in that I can then include it in other programs? And what happens when I use the options mentioned above like build and compile, because I see no new output files even though the build is successful - I'm guessing they go somewhere else I don't know about. I've googled this but I mostly find Xcode 4 stuff.
Thanks,
Ben.
Is there an Objective-C syntax checker?
I have tried gcc -fsyntax-only but it is not really 'syntax only'. It still produces errors if run on an individual implementation file which has references to external frameworks.
I am looking for something that can perform a syntax check on individual header or implementation files without attempting to link or produce object files.
Can gcc do this with additional flags I am unaware of, or is there another tool up to this task?
I want to do this from the command-line. Can xcodebuild do this for an individual file? Running xcodebuild for the entire project to check the syntax of one file is a bit much.
There's no way for it to check the syntax without it knowing about the header files for the frameworks you are using. You need to use the -framework flag to include the relevant header files.
You could try using clang -fsyntax-only instead, especially if you're using 10.6/Xcode 3.2. Clang/LLVM has much better separation between the parser and the other parts of the compiler chain. You can find clang in /Developer/usr/bin.
So after trawling through the gcc man page I discovered the -F flag which lets you add a framework directory to the list of directories gcc searches for header files.
This solves my issue.
Use it like this: gcc -fsyntax-only -ObjC -F/Path/To/A/Framework -F/Path/To/Another/Framework File.m
You can compile a single file in Xcode[1] using Build->Compile (cmd-K) which is effectively a syntax check (there's no linking step).
[1] I assume you're using Xcode, as there's little point in using Objective-C without OS X (really the Cocoa frameworks).