Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22072

using a Makefile in Xcode - or alternative IDE

$
0
0

I am new to Xcode, Makefiles, and to programming generally.

I have been given an existing C++ code to work with that is built using a Makefile. Using the Makefile I can build and run the executable on my Mac (MacOS 10.14.6) with no problem.

The start of the Makefile is

CC = g++-mp-9 -Wall -O2 -std=c++14 -fopenmp
DEBUG = 
CFLAGS = -c $(DEBUG) -I/opt/local/include
LFLAGS = $(DEBUG) -L/opt/local/lib -framework Accelerate -march=native -lfftw3 -lfftw3_threads -lopenblas -lm -lpthread -larmadillo

schrodinger_newton_2d: $(OBJS)
    $(CC) -o schrodinger_newton_2d $(OBJS) $(LFLAGS)

main.o: main.cpp const.h functions.h
    $(CC) $(CFLAGS) main.cpp
...

where schrodinger_newton_2d is the executable produced.

I want to use the debug features of Xcode 11 (or any modern IDE - see ALTERNATIVELY below) to explore and learn the code I want to use. Following these instructions I have created a command-line Xcode project and set up an external build target.

However when I try to build it in Xcode, I get the following error

g++-mp-9 -Wall -O2 -std=c++14 -fopenmp -c  -I/opt/local/include main.cpp
make: g++-mp-9: No such file or directory
make: *** [main.o] Error 1

This is strange because my Makefile works just fine, and on the command line my system can find the compiler:

>$ whereis gcc  
/usr/bin/gcc

Could someone please explain why Xcode can't find the compiler, and how I might fix it? (Also any tips/warnings about using Xcode to grok a code that is designed to be built using a Makefile would be appreciated!)

ALTERNATIVELY
I'm not wedded to the idea of using Xcode, I just thought it would be natural as I'm working on a mac. If there is another IDE with a good debugger that would be more suited to building a command-line executable using a Makefile then please let me know!


Viewing all articles
Browse latest Browse all 22072

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>