C preprocessor "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cpp" fails sanity check - c++

On macOS Mojave with Xcode 11.3, I have an Autotool based thirdparty lib builds just fine when running my build script in Terminal, but fails when run in Xcode Run Script step as ./"$BuildScript"
Showing All Messages
/configure:1:1: C preprocessor "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cpp" fails sanity check
This seems to correspond to my CPP variable in the script
export CPP=$(xcrun --find --sdk "${SDK}" cpp)
But I can't figure out why running the script AS IS in Terminal does not have the issue.
Does it have anything to do with Xcode's environment variables?
How should I fix this?
I've tried to switch to different compiler executables to no avail.

Related

Is environment configured incorrectly inside VSCode C++ debug session on OSX?

I have a programming language I'm fiddling with and it calls clang to link the bitcode file it emits. (Perhaps there is a better way to do this all together?) I've been using Visual Studio Code to debug it and it has mostly worked great.
I recently upgraded llvm. At that point, builtin osx clang was complaining about not recognizing a bitcode construct. So I installed clang part of llvm with brew. This looks to work for the compiler but fails to call the linker.
When I run a debug session I get this in the debug window:
clang-6.0: error: unable to execute command: Executable \"ld\" doesn't exist!
However, if I run from the embedded terminal it works fine.
It seems like clang is trying to explicitly expand the location of ld rather than using builtin path resolution. Something in VSCode's C++ debugger launched environment is causing issues with it.
Some supporting bits of diagnosis (trying to keep this a bit short for now...).
When run from the debugger:
whereis ld works and emits...
/usr/bin/ld
env emits what looks like a wrapped environment...
PWD=/Users/<snipped>
SHLVL=1
_=/usr/bin/env
echo $PATH emits...
/usr/gnu/bin:/usr/local/bin:/bin:/usr/bin:.
And clang tries to link it runs "ld" and says...
clang-6.0: error: unable to execute command: Executable "ld" doesn't exist!
When run from the embedded terminal on the other hand:
whereis ld works and emits...
/usr/bin/ld
env emits...
a metric ton of stuff including
PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin
echo $PATH emits...
/usr/gnu/bin:/usr/local/bin:/bin:/usr/bin:.
And clang tries to run "/usr/bin/ld" which works fine.
I realize this may be a clang ld lookup bug (not correctly expanding _=/usr/bin/env??). Unfortunately A) I don't know very much about OSX environment expansion B) if VSCode C++ debugger is using some sort of standard OSX environment jujitsu or not C) not sure how to debug clang run from within an existing VSCode debugger session D) don't know how to emulate the VSCode debugger environment setup to get started unravelling the ball of yarn.
I think I've upgraded OSX/XCode that I'm now unblocked (using the builtin clang compiler from within the VSCode debugger works again). I figured I'd raise this anyway in case I can get a problem fixed or at least learn something.
Any thoughts/suggestions?
Thanks,
Adrian

Cannot Run Compiler 'cl' for qt5.10.1 on Windows 10 in terminal

I have never used qt before, but I got a task to build an already existing application for Windows and Mac using the newest version of qt. What I have done so far is:
Installed Visual Studio Professional 2017.
Installed the latest Qt 5 Open Source.
Note: when installing the QT 5 I installed all of the components under QT/ QT 5.10.1 which were: qt 5.10.1 components and under QT/Tools I installed QT Creator 4.6.0 CDB Debugger Support and MinGW 5.3.0 : qt 5 Tools
I cloned the branch from GitHub that I wanted to build to C:/Projects
Then in Git Bash I cd to the project and tried to run qmake. The first time I had this problem:
"bash: qmake: command not found"
After searching into the problem I found out that I haven't added "Qt/5.10.1/msvc2017_64/bin" to PATH and I added it. Now when I echo $PATH I can see the directory added.
Now after bash recognises qmake and I try to run it it says:
Project ERROR: Cannot run target compiler 'cl'. Output:
===================
Maybe you forgot to setup the environment?
I have no idea how to fix the problem due to the fact that I have never used QT to build anything before. Can you help me?
In the read me file for the application I am trying to build it says:
Step-by-step instructions
1. Clone this branch
2. cd into the project
3. Run qmake - this wil generate Makefiles for all of the project's modules
4.Run make (Use the -j4 of -j flags - this greatly speeds up the build process - see the manual page for make for more info). You can also use the -s flag to silence the output - this also wins you a few seconds.
I am a bit puzzled by the instructions, it does not say to run qmake -project anywhere, but there is a qt project file in the directory that I cd to. Does this mean that I don't have to run qmake -project?
Also I have no idea how to run make by using the -j4 and -j flags and how to run flags in general. Could someone help me?
I believe that for the Cannot Run Compiler 'cl' issue I have some kind of a problem with the set up. Did I install too many components or is it to do with the VS setup?
I highly recommend you to install Qt from the Qt installer, and to use Qt Creator.
However, if you want to use it from source, you first need to get a compiler (ex: MinGW). Then you need to execute the instructions, but you need to use a MinGW (or whatever compiler you use) command prompt, which will automatically set the environment variables needed.
Note that this is Windows specific. On mac and linux, the compiler's environment variables are already set in the default command prompt (if there is a compiler, obviously).

CodeLite - build settings malfunction

from unknown reason I can't compile a single file/project in C++ in my CodeLite environment.
I'm using latest version of CodeLite, i.e.: 7.0 with pre-installed MinGW libraries. OS/ Windows 7.
Strangely after reinstallation, time and again I get the following error while trying to build/compile C++ project:
C:\Windows\system32\cmd.exe /C " -j 2 -e -f Makefile"
Name'-j' is not recognized as an internal or external command operable program or batch file
When I try to run the program (I was used to click run and get immediate results since it was compiling and running the code at one time) I get absolutely nothing.
Any idea how can I fix this strange issue ? Reinstalling IDE doesn't really help :(
C:\Windows\system32\cmd.exe /C " -j 2 -e -f Makefile".
Do you have MinGW installed? CodeLite 7.0 does not come with MinGW
To fix your problem:
Install MinGW, I recommend using TDM-GCC (make sure you accept the default options by TDM-GCC installer, especially, the install location path)
After the installation is completed, let CodeLite detect your compiler: Settings->Build Settings->Compilers->Add Compiles->Add an existing compiler and point CodeLite to the folder where you installed MinGW
You should now have this compiler configured in CodeLite. right Click on your project and open the settings dialog (keyboard shortcut Alt-F7) : Project settings->Common Settings->General->Compiler and select your compiler from the list
Build your project again, this time it should work properly.
Also, I recommend you to use the latest weekly build (it contains a new "setup wizard" that includes installing a compiler), you can get it from codelite's downloads page
Eran

Recipe for target failed error in Eclipse using cygwin

First of all, I know that this question already exists multiple times in Stackoverflow but the answers provided for all of them didn't solve my issue(See section "Solutions worked for others" at the end of this question).
I am using the Eclipse IDE(Juno) with CDT plugin and Cygwin installed in my Windows-7 64-bit platform.
I successfully compiled and run the Hello World 'C' program but the Hello World "C++ program" is having Launch failed. Binary not found error.
I am also having recipe for target project.exe failed error in my auto-generated makefile.
Error line in makefile: #echo 'Building target: $#'
Additionally:
In c/c++ build -> toolchain editor ->
Current toolchain : Cygwin GCC
Current Builder : Gnu Make Builder
Used Tools:
GCC Assembler,
GCC Archiver,
Cygwin C++ Compiler,
Cygwin C Compiler,
Cygwin C Linker,
Cygwin C++ Linker.
When I change Current Builder from "Gnu Make Builder" to "CDT Internal Builder" the recipe for target project.exe failed error disappears but the Launch failed. Binary not found error still exists.
And also I dont have MinGW installed.
Solutions worked for others :
Before running the project directly using the run command, first Build the project and then run.
I build the project every time before I run it.
Eclipse can't find or point to an .exe file but the exe file runs fine when run from windows explorer and the answer to it is add -arch i386 to miscellaneous under linker.
My build runs without error but not creating the exe file. So this doesnt apply to me
Project->Properties->C/C++ Build->Settings->Binary Parsers
set "Cygwin PE Parser" and/or " PE Window Parser" and alike.
Tried all of them with different combinations but did not work
I also did :
adding the cygwin install dir to the path variable
added all the includes folders needed for cygwin for both GNU C and GNU C++ in Paths-and-Symbols -> includes
Saved the project before building and then running
restarted eclipse again
checked if g++ is installed using which g++ in terminal
and so on.
What could be a fix to this problem? Or do I have to install MinGW (I tried already to install MinGW with the installer.exe they provided and it failed on downloading the files several times) and try again.
I couldn't find the solution. Please show me what am I missing here.
Thanks in advance.

Cannot run C/C++ project on eclipse+cygwin+cdt

As we all know, Eclipse can not only run Java project, It also can run C/C++, Python, PHP etc, but we need to install plugins and configure run environment. I want to run C++ Project on Eclipse+cygwin+cdt (Windows 7), I have added following these environment variables.
"C:\cygwin64\usr\include"
"C:\cygwin64\lib"
"C:\cygwin64\bin"
and configure Eclipse toolchain = CygwinGcc and binary parsers = PE Windows Parser, I also set sth about "Paths and Symbols", but I still cannot run C/C++, following is the error info:
"Lauching CTest Debug" has encounted a problem. The program file specied in the launch configuration does not exist."
there is no binaries files, is there something wrong with it? I'm confused.
An executable probably doesn't exist in your debug folder.
There is a thread on how to get c++ running on Eclipse here:
The program file specified in the launch configuration does not exist
Hope that solves your problem
Did you install gcc toolchain successfully in Cygwin? Try to include gcc, gdb and make when you install cygwin.