When i run the executable after make, bash raise following error:
$ ./prog
-bash: ./prog: cannot execute binary file
My makefile:
CC = g++ -std=c++11
LDFLAGS = -undefined dynamic_lookup -bundle
OBJ = main.o datetime.o logger.o WeatherApi.o tinyxml2.o tflower.o tservo.o
prog: $(OBJ)
$(CC) -o $@ $(OBJ) $(LDFLAGS)
%.o: %.cpp
$(CC) -c $<
clean:
rm -r *.o
What did i wrong?
Update 2:
Thanks for your comment SergayA. After link python with the help of this article it works.
Update 1:
I removed the -undefined dynamic_lookup -bundle flag after some comments so i got problems with Python. To use Python.h i set the environment variable to this path:
CPLUS_INCLUDE_PATH=/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/
2 warnings generated.
g++ -std=c++11 -c datetime.cpp
g++ -std=c++11 -c logger.cpp
g++ -std=c++11 -c WeatherApi.cpp
g++ -std=c++11 -c tinyxml2.cpp
g++ -std=c++11 -c tflower.cpp
g++ -std=c++11 -c tservo.cpp
g++ -std=c++11 -o prog main.o datetime.o logger.o WeatherApi.o tinyxml2.o tflower.o tservo.o
Undefined symbols for architecture x86_64:
"_PyDict_GetItemString", referenced from:
WeatherApi::SayHelloWorld() in WeatherApi.o
WeatherApi::GetAirTemperature() in WeatherApi.o
"_PyErr_Print", referenced from:
WeatherApi::WeatherApi(char*, char*) in WeatherApi.o
WeatherApi::GetAirTemperature() in WeatherApi.o
"_PyImport_Import", referenced from:
WeatherApi::WeatherApi(char*, char*) in WeatherApi.o
"_PyModule_GetDict", referenced from:
WeatherApi::WeatherApi(char*, char*) in WeatherApi.o
"_PyObject_CallObject", referenced from:
WeatherApi::SayHelloWorld() in WeatherApi.o
WeatherApi::GetAirTemperature() in WeatherApi.o
"_PyString_AsString", referenced from:
WeatherApi::GetAirTemperature() in WeatherApi.o
"_PyString_FromString", referenced from:
WeatherApi::WeatherApi(char*, char*) in WeatherApi.o
WeatherApi::GetAirTemperature() in WeatherApi.o
"_PyTuple_New", referenced from:
WeatherApi::GetAirTemperature() in WeatherApi.o
"_PyTuple_SetItem", referenced from:
WeatherApi::GetAirTemperature() in WeatherApi.o
"_Py_Finalize", referenced from:
WeatherApi::~WeatherApi() in WeatherApi.o
"_Py_Initialize", referenced from:
WeatherApi::WeatherApi(char*, char*) in WeatherApi.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [prog] Error 1
file progtell you?-undefined dynamic_lookup -bundle. So edit your question to improve it and add more explanation about yourMakefile. If you don't know why you use that you need to remove it from yourMakefile. Most programs don't need such extra linker flags.