clang ‘-rewrite-objc main.m’ error - c++

I want to use clang convert Object - C to C + +, quoted error is as follows:
userdeMac-mini:Demo xxx$ clang -rewrite-objc main.m
main.m:9:9: fatal error: 'UIKit/UIKit.h' file not found
import <#UIKit/UIKit.h>
1 error generated.
Excuse me, how should solve ?

This works for me. You can try by changing the path according to your SDK location.
clang -x objective-c -rewrite-objc -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.1.sdk ViewController.m

main.m:9:9: fatal error: 'UIKit/UIKit.h' file not found
That means that the UIKit headers can't be found. Do you have the iOS SDK installed somewhere? Have you configured the search paths in your makefile (or build environment) correctly?
The easiest way to start investigation is to start with a working Xcode project, compile a single .m file, and then see the command line that was used to compile that file. The clang rewriter takes slightly different options, but the search paths and a lot of the other configuration are the same.

First of all, you should use the "cd" command to enter to "clang - rewrite - objc" file directory, then use a command such as "clang - x objective - c - rewrite - objc - isysroot/Applications/Xcode. The app/Contents/Developer/Platforms/iPhoneSimulator platform/Developer/SDKs/iPhoneSimulatorX X.s dk X.m", the "X" is the version of your iPhoneSimulator and "clang - rewrite - objc" file name.

Related

Xcode command line tools not finding header files (Catalina Update 10.15.7)

Recently I have updated my MacBook operating system to Catalina 10.15.7 and Xcode command line tools to 12.1. Ever since I have been getting the following error when I try to use any C++ compiler:
gcc A3v2.cpp
In file included from /usr/local/include/c++/9.2.0/bits/postypes.h:40,
from /usr/local/include/c++/9.2.0/iosfwd:40,
from /usr/local/include/c++/9.2.0/ios:38,
from /usr/local/include/c++/9.2.0/ostream:38,
from /usr/local/include/c++/9.2.0/iostream:39,
from A3v2.cpp:13:
/usr/local/include/c++/9.2.0/cwchar:44:10: fatal error: wchar.h: No such file or directory
44 | #include <wchar.h>
| ^~~~~~~~~
compilation terminated.
I have tried removing and re installing command line tools but it hasn't worked (amongst trying various other solutions I've found on Stackoverflow). When I run sudo find on wchar.h I get the following.
sudo find /Library -name wchar.h
find: /Library/Application Support/com.apple.TCC: Operation not permitted
/Library/Developer/CommandLineTools/usr/include/c++/v1/wchar.h
/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/wchar.h
As a current work around (as I need a c++ compiler for a current assignment) I have been using:
/usr/bin/gcc A3v2.cpp
however I'm hoping this will just be temporary. I think this is a path problem since the missing header file exsits? Not sure what I am doing when it comes to specifying file paths so please let me know if you know how to solve this. Thanks!

Program won't start because libmpc-3.dll is missing

I'm trying to compile c++ code in Notepad++. The command I'm running is as follows in the Program to Run box.
C:\MinGW\bin\g++.exe -o "$(NAME_PART)" "$(FULL_CURRENT_PATH)"
I get the error saying "The program can't start because libmpc-3.dll is missing...". I checked the MinGW file path and the libmpc-3.dll file is there in the bin folder.
Why would it say the file is missing, or is there something wrong with my command?
Please take a look at this solved question:
MinGW gcc -> libmpc-3.dll missing on 64-Bit Windows 7
Maybe it helps you.

mex error 206 Matlab

The cpp code I received for a project isn't working so I want to compile and see if it compiles. It didn't compile, but I tried compiling another cpp file that I know works just to see what would happen. In both cases I get the following error:
EDU>> mex max.cpp
xcodebuild: error: SDK "macosx10.7" cannot be located.
xcrun: error: unable to find utility "clang++", not a developer tool or in PATH
mex: compile of ' "max.cpp"' failed.
Any suggestions how I can either fix the cpp file or maybe I'm not running this correctly? Can't figure out where to go from here.
EDIT:
I figured it out. My mexopts.sh file was pointing to an old version of mac so I had to manually edit that file and change 10.7 to 10.9.
I figured it out. My mexopts.sh file was pointing to an old version of mac so I had to manually edit that file and change 10.7 to 10.9.

Compiling DISLIN gfortran

I am having trouble compiling Fortran code with references to DISLIN. I have downloaded DISLIN from the website, unzipped the file and ran the setup. I have added an environment variable called DISLIN (C:\dislin) and added C:\dislin\win to the PATH section of my system variables.
I am trying to compile some example code of the DISLIN website which includes line
USE DISLIN
I am using a MinGW shell to compile with command gfortran -o progrname -ldislin EX11_1.f90 and am getting the following error:
Fatal Error: Cant open module file 'dislin.mod' for reading at (1): No such file or directory.
I have tried changing the variable path and even moving the dislin.mod file (which is there) but still get the same message.
Ok I fixed this problem so thought I come back and post what worked for me incase any one else needs it...
Install both DISLIN and MinGW on the c drive
Copy disgf.a from /c/dislin and dislin.f90 from /c/dislin/gf into the directory containing your fortran files
(for me this is /c/MinGW/pnote)
Using the MinGW shell navigate to you files: cd /c/MinGW/pnote
compile dislin.f90 and your fortran program: gfortran -c dislin.f90 progName.f90 (dislin.f90 obviously only needs to be done once)
link libraries etc and compile: gfortran progName.o disgf.a -luser32 -lgdi32 -lopengl32 -o exeName
'run' exeName
You probably need to specify the path to the DISLIN module files:
gfortran EX11_1.f90 -o progrname -ldislin -I/path/to/DISLIN/modules
and, if not already configured like described here, also the path to the library itself:
gfortran EX11_1.f90 -o progrname -ldislin -I/path/to/DISLIN/modules \
-L/path/to/DISLIN/library
They provide a batch file (windows) to do the compiling and linking for you.
f90link -c My_Program
This is located in c:\dislin\Win
Also, if you are having trouble with the dislin.mod file which resides in c:\dislin\gf then recompile that with the -c compile option. I found all of this info in c:\dislin\readme.inf
near as I can tell (Jan 2018) dislin (64 bit) fails miserably with gfortran 7.2, period; and probably with many other newer compilers.
When trying to link, gfortran 7 says 'dislin.mod' is an unrecognizable format.
I think this program is highly dependent on exactly correct version synchronization - something that renders such software useless imho after many years in research.
and no, the correctness of various 'paths' seems not to help.
after all, gnuplot works, "at all". Not sure why I spent so much time on brand x.
jrc

why am i seeing this libzdb configure error?

I am attempting to install libzdb on my macbook however I see the following error message when running the configure:
configure:13334: error: setjmp is required
the setjmp.h file resides within /usr/include and is specified within my "$PATH" as
/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/usr/include
Can someone please advise as to how i can rectify this issue?
thanks in advance
I've stumbled across this error while building one of my own programs when I wanted to use setjmp() and longjmp(). For some reason, the toolchain that resides in / on OS X is flawed, and the <setjmp.h> header file is missing the declarations and data types.
To fix it, I had to download Xcode (damn!) and tell the compiler to look for the headers in the freshly installed MacOSX10.7.sdk (or 8) folder:
clang -Wall -o foo foo.c -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk
ok finally figured it out. For those who have seen messages like this be warned that the configure logs can be misleading. It turned out the binary built fine, however it was failing during runtime because a few mysql libraries could not be found. using the following command *export DYLD_LIBRARY_PATH=/usr/local/mysql/lib/* would fix the problem