Private MobileDevice.framework not discovered from clang anymore with the -F/System/Library/PrivateFrameworks switch - objective-c

I am working with the mobiledevice device app from https://github.com/imkira/mobiledevice.
But since the latest Mac OSX update 10.13.02 (17C88) I can't compile the mobiledevice app anymore because clang complains about not finding the private "MobileDevice" framework searched in /System/Library/PrivateFrameworks.
$ git clone https://github.com/imkira/mobiledevice
$ cd mobiledevice
$ make
clang ... -o mobiledevice ... -framework MobileDevice -F/System/Library/PrivateFrameworks -DMOBILEDEVICE_CLI_VERSION=\"2.0.0\" -DMOBILEDEVICE_CLI_REVISION=\"8134c5e7edd97bf718490eaadb3639bda276e596\" cli.m commands.m device.m get_app_prop.m get_bundle_id.m get_device_prop.m help.m install_app.m invalid_usage.m list_app_props.m list_apps.m list_device_props.m list_devices.m tunnel.m uninstall_app.m version.m
ld: framework not found MobileDevice
clang: error: linker command failed with exit code 1 (use -v to see invocation)
But I can see that the framework still exists in the directory /System/Library/PrivateFrameworks.
It seems that clang is filtering out the -F/System/Library/PrivateFrameworks switch.
Any hints how to fix the issue ?

The accepted answer does not work for me on Big Sur. I've found not supplying /System/Library/PrivateFrameworks but instead /Library/Apple/System/Library/PrivateFrameworks solves it.

Answering my own question I found out that copying the MobileDevice.framework to another location (.) and setting the framework path to that location makes clang recognise the private framework.
So its a clear indicator for me that clang has filtered out the -F/System/Library/PrivateFrameworks switch.
$ cp -a /System/Library/PrivateFrameworks/MobileDevice.framework ./MobileDevice.framework/
$ clang .. -o mobiledevice ... -framework MobileDevice -F.
gives no "framework not found" error anymore

Related

wxWidgets 2.9.4 + Xcode 4.5.2 - Can't make it work

I'm having troubles trying to use wxWidgets 2.9.4 and Xcode 4.5.2, I get all sort of errors in the way.
First of all, I think I installed wxWidgets correctly, because every sample and demo run just fine. The problem is when I try to create an Xcode project.
When I follow the wxWidgets tutorial changing the build settings as follows:
Paste the --cppflags in "Other C++ Flags"
Paste the --libs in "Other Linker Flags" (REMOVING THE -L)
Change the compiler to GCC
I get:
ld: library not found for -lwxregexu-2.9
clang: error: linker command failed with exit code 1 (use -v to see invocation)
When I follow the http://zebratale.tumblr.com tutorial (seems more detailed to me)
I get:
ld: library not found for -lwx_osx_cocoau_xrc-2.9
clang: error: linker command failed with exit cod 1 (use -v to see invocation)
I'm completely lost and I'd appreciate any help
------------UPDATE------------------------
I just found out that it's possible to compile it using the terminal command:
g++ -o main main.cpp './../../build-cocoa-debug/wx-config --debug --cxxflags --libs'
So I guess the problem is the compiler Xcode is using. But when I change it to LLMV GCC 4.2, I get the same error (YES, as if it was still using clang)
To change the compiler I went to build settings->build options->compiler for c/c++/objective-c and changed it.
---------UPDATE2-----------------
Even now that I changed the compiler on Xcode the error is:
ld: library not found for -lwx_osx_cocoau_xrc-2.9
collect2: ld returned 1 exit status
Command /Applications/Xcode.app/Contents/Developer/usr/bin/llvm-g++-4.2 failed with exit code 1
First, use --cxxflags (C++ compiler flags), not --cppflags (C preprocessor flags).
Second, why do you remove -L? Of course the linker can't find the libraries if you remove the option telling it where they are.

Problems when compiling Objective C with Clang (Ubuntu)

I'm learning Objective-C language. Since I don't have a Mac, I'm compiling and running my code within Ubuntu 11.04 platform.
Until now, I was using gcc to compile. I've installed GNUStep and all was working. But then I started to try some Objective-C 2.0 features, like #property and #synthesize, that gcc does not allow.
So I tried to compile the code with Clang, but it seems that it is not correctly linking my code with the GNUStep libraries, not even with a simple Hello world program.
For example, if I compile the following code:
#import <Foundation/Foundation.h>
int main(void) {
NSLog(#"Hello world!");
return 0;
}
The output of the compiler is:
/tmp/cc-dHZIp1.o: In function `main':
test.m:(.text+0x1f): undefined reference to `NSLog'
/tmp/cc-dHZIp1.o: In function `.objc_load_function':
test.m:(.text+0x3c): undefined reference to `__objc_exec_class'
collect2: ld returned 1 exit status
clang: error: linker (via gcc) command failed with exit code 1 (use -v to see invocation)
The command I'm using to compile is
clang -I /usr/include/GNUstep/ test.m -o test
with the -I directive to include the GNUStep libraries (otherwise, Clang is not able to find Foundation.h).
I've googled my problem, and visited both GNUStep and Clang web pages, but I haven't found a solution to it. So any help will be appreciated.
Thanks!
The problem was that the library gnustep-base was not being used by the linker. So the solution to this was using the option -Xlinker, that sends arguments to the linker used by clang:
clang -I /usr/include/GNUstep/ -Xlinker -lgnustep-base test.m -o test
The statement "-X linker -lgnustep-base" made the magic. However, I had problems with this command related to the class that represents a string in Objective-C:
./test: Uncaught exception NSInvalidArgumentException, reason: GSFFIInvocation:
Class 'NXConstantString'(instance) does not respond to forwardInvocation: for
'hasSuffix:'
I could solve it adding the argument "-fconstant-string-class=NSConstantString":
clang -I /usr/include/GNUstep/ -fconstant-string-class=NSConstantString \
-Xlinker -lgnustep-base test.m -o test
In addition, I've tried with some Objective-C 2.0 pieces of code and it seems to work.
Thank you for the help!
You can try gcc compiler:
First of all install GNU Objective-C Runtime: sudo apt-get install gobjc
then compile: gcc -o hello hello.m -Wall -lobjc
You are not able to use ObjC 2.0 features because you're missing a ObjC-runtime supporting those. GCC's runtime is old and outdated, it doesn't support ObjC 2.0. Clang/LLVM doesn't have a acompanied runtime, you need to install the ObjC2-runtime from GNUstep (which can be found here: https://github.com/gnustep/libobjc2 ) and reinstall GNUstep using this runtime.
Here are some bash scripts for different Ubuntu versions, that do everything for you:
http://wiki.gnustep.org/index.php/GNUstep_under_Ubuntu_Linux
And please don't try to reinvent GNUstep make, instead, use it:
http://www.gnustep.org/resources/documentation/Developer/Make/Manual/gnustep-make_1.html
If you really don't think so, here is some excerpt from there:
1.2 Structure of a Makefile
Here is an example makefile (named GNUmakefile to emphasis the fact that it relies on special features of the GNU make program).
#
# An example GNUmakefile
#
# Include the common variables defined by the Makefile Package
include $(GNUSTEP_MAKEFILES)/common.make
# Build a simple Objective-C program
TOOL_NAME = simple
# The Objective-C files to compile
simple_OBJC_FILES = simple.m
-include GNUmakefile.preamble
# Include in the rules for making GNUstep command-line programs
include $(GNUSTEP_MAKEFILES)/tool.make
-include GNUmakefile.postamble
This is all that is necessary to define the project.
In your case replace all occurrences of simple with test and you're done
1.3 Running Make
Normally to compile a package which uses the Makefile Package it is purely a matter of typing make from the top-level directory of the package, and the package is compiled without any additional interaction.

How to compile objc code on Linux?

Assuming you have your .h and .m ready on a Linux server, which command would you issue to GCC to have it compiled?
The relevant parts:
gcc -c -Wno-import List.m
gcc -o prog -Wno-import List.o main.o -lobjc
. . . make sure that the Objective-C library and header files (objc/Object.h) were installed when gcc was built.
Note that when linking Objective-C with gcc, you need to specify the Objective-C library by using the -lobjc switch.
See this link for more information.
Additional link with possible solution to the missing compiler issue:
Try installing either gobjc++ or gobjc
sudo apt-get install gobjc++
gcc -x objective-c file.m -o out
Google is your friend

Error installing mod_wsgi 3.2

I am trying to install mod_wsgi 3.2 on Mac OSX 10.6.6 and am getting this error when I attempt to make
Installed assemblers are:
/usr/bin/../libexec/gcc/darwin/x86_64/as for architecture x86_64
/usr/bin/../libexec/gcc/darwin/i386/as for architecture i386
lipo: can't open input file: /var/folders/XW/XWYalsEzG3Gkn+PhoNKF0k+++TI/-Tmp-//ccsEgbTa.out (No such file or directory)
apxs:Error: Command failed with rc=65536
.
make: * [mod_wsgi.la] Error 1
This is a late answer, but I found a solution in my searching and wanted to include it here for others. This error typically occurs because you are trying to build libraries for ppc architecture which won't work as xcode4 doesn't no longer includes support for ppc. You can get around this by setting the following in your environment before running your build (I put this in my .bash_profile so I don't beat my head against the wall later):
export ARCHFLAGS="-arch i386 -arch x86_64"
The latest mod_wsgi version is 3.3 for a start, why are you using 3.2? Second, there is a precompiled mod_wsgi.so binary for MacOS X which can be used for Apple supplied Python and Apache, so you do not need to compile it from source code and so avoid need to have installed XCode development tools. The precompile mod_wsgi.so is available from mod_wsgi download page.
As to the errors, it would appear to be a permissions problem for user that you are compiling as. That or you aren't using standard Apple supplied software and have somehow mixed up your PATH so it is grabbing disparate tools from different package distributions. Are you using just Apple tools or have you installed any of MacPorts, fink or HomeBrew?
Edit the Make file like:
CPPFLAGS = -I/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -DNDEBUG
CFLAGS = -Wc,"-arch i386" -Wc,"-arch x86_64" -Wc
LDFLAGS = -arch i386 -arch x86_64 -F/Library/Frameworks -framework Python -u _PyMac_Error
LDLIBS = -ldl -framework CoreFoundation
I had the same question
In the end,I found I don't have write permission of '/usr/libexec/apache2/'
then I add chmod +w to the folder,,
then install success !!
Hope my answer can be a refer for some others
Good Luck!

Linking error with g++ 3.4.4 and g++ 3.4.5

Using: windows xp, g++ 3.4.4 with cygwin and g++ 3.4.5 with mingw.
I'm compiling a simple unit test class with cppunit.
When I link using g++ 3.4.5 I get a lot of linking errors. When I link with g++ 3.4.4 I don't get any errors and the exe links fine and runs.
I can't seem to trace down the errors, so any thoughts?
Thanks.
EDIT: linking errors: Unreferenced function errors. Like:
SimpleTest.cpp:(.text+0x313): undefined reference to `CppUnit::Message::Message(std::string const&, std::string const&)'
EDIT: cmd line:
g++ -I g:\projects\thirdparty\cppunit-1.12.1\include -L g:\projects\thirdparty\cppunit-1.12.1\lib -l cppunitd -o main.exe main.cpp SimpleTest.cpp
Update: Same code in Visual Studio: No error, unit test runs as expected.
Your problem is likely incorrect link line. The order of sources/object files and libraries on the link line matters. Correct link line:
g++ -I g:\projects\thirdparty\cppunit-1.12.1\include \
-L g:\projects\thirdparty\cppunit-1.12.1\lib \
-o main.exe main.cpp SimpleTest.cpp -lcppunitd
As g++ matures, I'm on 4.2.3, it's type checking has gotten more pedantic and for that matter better. With the little information I'd say it's likely that you should look closely at your calls to these methods. I suspect that the types are not quite right. 3.4.4 doesn't catch it, 3.4.5 does.
....JW
One thing you could perhaps try is to compile with g++ 3.4.5 and/or 3.4.4 on Linux. If the result then is the same, then it is clearly a property of gcc. Otherwise it more sounds like a mingw issue.