I have a problem with the following makefile in Windows. Although it worked in Linux, I get an error now using MinGW in Windows.
I checked the article on this page: Compile using MakeFile in Window, but I still have no success.
CC = c++
CFLAGS = -Wall -g
ODIR = /OBJ
CFILES := $(wildcard SRC/*.cpp)
OFILES := $(addprefix OBJ/,$(notdir $(CFILES:.cpp=.o)))
meshl: $(OFILES)
$(CC) $(CFLAGS) -o $# $(OFILES)
OBJ/%.o: SRC/%.cpp
$(CC) $(CFLAGS) -c $< -o $#
clean:
rm -f OBJ/*.o
When I try to compile it in the command prompt, the following message appears:
OBJ/mpoint.o: file not recognized: File format not recognized
collect2.exe: error: ld returned 1 exit status
makefile:9: recipe for target 'meshl' failed
make: ***[meshl] Error 1
Thanks for your time and help!
Related
I have trouble with include uaplatformlayer.h in example from OPCUA client example.
I found this example in SDK. I tried to do own makefile, to build example client lesson01.
I use Visual Studio Code. It can't find this .h file.
#include "uaplatformlayer.h"
#include "sampleclient.h"
int main(int, char*[])
{
UaStatus status;
// Initialize the UA Stack platform layer
UaPlatformLayer::init();
// Create instance of SampleClient
SampleClient* pMyClient = new SampleClient();
return 0;
}
it still replies...
g++ -g -Wall -c client_cpp_sdk_tutorial.cpp
client_cpp_sdk_tutorial.cpp:1:10: fatal error: uaplatformlayer.h: Adresář nebo soubor neexistuje
1 | #include "uaplatformlayer.h"
| ^~~~~~~~~~~~~~~~~~~
compilation terminated.
make: *** [Makefile:9: client_cpp_sdk_tutorial.o] Chyba 1
The terminal process "bash '-c', '/home/michal/Dokumenty/OPCUA_adapter/sdk/examples/client_gettingstarted/lesson01/build.sh'" failed to launch (exit code: 2)
I think my problem is in makefile, but I don't have any idea where is the mistake.
Could anyone help me, please?
Does anyone experiance with OPCUA SDK?
cc=g++
cflags=-g -Wall
libflags=-L/home/michal/Dokumenty/OPCUA_adapter/sdk/lib -luamoduled -luamodelsd -lcoremoduled -luabasecppd -luastackd -lxmlparsercppd -luapkicppd -luaclientcppd -lxml2 -lssl -lcrypto
includes=-I/home/michal/Dokumenty/OPCUA_adapter/sdk/include/uabasecpp -I/home/michal/Dokumenty/OPCUA_adapter/sdk/include/uastack
objfiles=client_cpp_sdk_tutorial.o sampleclient.o
vystup=aplikace
%.o : %.cpp
$(cc) $(cflags) -c $<
# startovaci pravidlo
vychozi: $(vystup)
# zavislosti
dep:
$(cc) -MM *.cpp >dep.list
-include dep.list
clean:
rm aplikace $(objfiles)
# slinkování aplikace
$(vystup): $(objfiles)
$(cc) $(cflags) $(objfiles) $(includes) $(libflags) -o $#
You need to add "includes" to the recipe for the .o files:
%.o : %.cpp
$(cc) $(cflags) $(includes) -c $<
I've started to code on Visual Studio Code (I was coding on IDE before) and to make project I learned that you need to do a makefile to link the file in your project.
So i searched a lot of tuto and i come up with this:
DEBUG=yes
CXX=g++
ifeq ($(DEBUG),yes)
CXXFLAGS=-W -Wall -ansi -pedantic -g
LDFLAGS=
else
CXXFLAGS=-W -Wall -ansi -pedantic
LDFLAGS=
endif
OBJDIR:= obj
EXECDIR:= bin
VPATH=src
EXEC=$(VPATH)/prog
SRC= $(wildcard src/*.cpp)
OBJECTS= main.o hello.o
OBJ= $(addprefix $(OBJDIR)/,$(OBJECTS))
all : $(EXEC)
ifeq ($(DEBUG),yes)
#echo "Generation en mode debug"
else
#echo "Generation en mode release"
endif
$(EXECDIR)/$(EXEC): $(OBJ) | $(EXECDIR)
$(CXX) $(CXXFLAGS) -o $# $^
$(EXECDIR):
mkdir $(EXECDIR)
$(OBJDIR)/main.o: src/hello.hpp
$(OBJDIR)/hello.o: src/hello.hpp
$(OBJDIR)/%.o: src/%.cpp | $(OBJDIR)
#$(CXX) -o $# -c $< $(CXXFLAGS)
$(OBJDIR):
mkdir $(OBJDIR)
.PHONY: clean mrproper
clean:
#rm -rf *.o
mrproper: clean
#rm -rf $(EXEC)
but I have a little problem ...
xe: cannot open output file /prog.exe: Permission denied
collect2.exe: error: ld returned 1 exit status
mingw32-make: *** [makefile:26: /prog] Error 1
And i really don't know why it is doing this
I am getting the fatal error while compiling a program (using make). Is it because of some permission issues?
make -C src/hash_function
make[1]: Entering directory `....../src/hash_function'
g++ -std=c++11 -Wall -pedantic -funsigned-char -msse4.2 -I "/export/SOFTWARE/boost_1_61_0" -MMD -c farmhash.cpp -o ../../obj/farmhash.o
farmhash.cpp:1965:1: fatal error: opening dependency file ../../obj/farmhash.d: No such file or directory
} // namespace NAMESPACE_FOR_HASH_FUNCTIONS
^
compilation terminated.
make[1]: *** [../../obj/farmhash.o] Error 1
The Makefile looks like the following and I am bit confused how I handle ../../obj/farmhash.o
CC = g++
CCFLAGS = -std=c++11 -Wall -pedantic -funsigned-char -msse4.2
LDFLAGS =
INCLUDE = -I "/export/SOFTWARE/boost_1_61_0"
EXE = main
AUXFLAGS =
OPTFLAGS =
LIBS = main.a index.a hash_map.a hash_function.a utils.a
LIBS := $(addprefix lib/,$(LIBS))
all: build/$(EXE)
run: all
clear
./build/$(EXE) $(INPUT) $(QUERIES)
build/$(EXE): libs
$(CC) $(LDFLAGS) $(OPTFLAGS) $(LIBS) $(AUXFLAGS) -o $#
libs:
$(MAKE) -C src/hash_function
$(MAKE) -C src/hash_map
$(MAKE) -C src/index
$(MAKE) -C src/main
$(MAKE) -C src/utils
.PHONY: clean
clean:
rm -f build/main
rm -f lib/*.a
rm -f obj/*.d obj/*.o
rebuild: clean all
I am trying to compile some C to run on a friendlyARM for days now without any luck, i think im close but getting this error:
kevin#kevin-VirtualBox:~/Desktop/makef$ make
arm-none-linux-gnueabi-gcc -c -o obj/main.o main.c -I./
as: unrecognized option '-mcpu=arm1176jzf-s'
make: *** [obj/main.o] Error 1
Does anyone know how to what this error means and how to fix it?
steps i have tried:
1
touch *.*
make clean
make
(error as: unrecognized option '-mcpu=arm1176jzf-s)
2
touch *.*
make clean
make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi-l
(error as: unrecognized option '-mcpu=arm1176jzf-s)
the Makefile :
IDIR =./
CC=arm-none-linux-gnueabi-gcc
CFLAGS=-I$(IDIR)
ODIR=obj
LDIR =./
LIBS=-lgd -lrt
_DEPS = main.h Makefile
DEPS = $(patsubst %,$(IDIR)/%,$(_DEPS))
_OBJ = main.o serial.o fb.o menu_main.o timer.o cmdin.o buzzer.o statemachine.o inout.o network.o text_file_input.o text_file_input_oven.o
OBJ = $(patsubst %,$(ODIR)/%,$(_OBJ))
$(ODIR)/%.o: %.c $(DEPS)
$(CC) -c -o $# $< $(CFLAGS)
main: $(OBJ)
$(CC) -o $# $^ $(CFLAGS) $(LIBS)
.PHONY: clean
clean:
rm -f $(ODIR)/*.o *~ core $(INCDIR)/*~
It means the version of gcc that you have installed does not understand the option -mcpu=arm1176jzf-s
Either you have an older version of gcc which does not accept that option, or you have a version of gcc that has cross compiling support turned off.
I'm working in windows and want to send data from C++ to Matlab. I've gotten the impression this is done most easy creating a makefile. Therefore I've installed cygwin to use the make command.
My makefile is as follows:
CXX = g++
CFLAGS = -O3 -I /cygdrive/c/Program\ Files/MATLAB/R2011a/extern/include
LIBS = -L /cygdrive/c/Program\ Files/MATLAB/R2011a/extern/lib/win64/microsoft/
LIBS2 = -L /cygdrive/c/Program\ Files/MATLAB/R2011a/extern/lib/win64/microsoft/libmx.lib
LDFLAGS = -leng -lmx
RKspace2d: RKspace2d.o
$(CXX) -o $# $^ $(LDFLAGS) $(LIBS)
RKspace2d.o: RKspace2d.cpp
$(CXX) -c $(CFLAGS) $(LIBS) $<
# $# name of the target
# $^ name of all prerequisites with duplicates removed
# $< name of the first prerequisite
When I type in "make" in the cygwin terminal, being in the right directory I get the following error:
$ make
g++ -o RKspace2d RKspace2d.o -leng -lmx -L /cygdrive/c/Program\ Files/MATLAB/R2011a/extern/lib/win64/microsoft/
/usr/lib/gcc/i686-pc-cygwin/3.4.4/../../../../i686-pc-cygwin/bin/ld: cannot find -leng
/usr/lib/gcc/i686-pc-cygwin/3.4.4/../../../../i686-pc-cygwin/bin/ld: cannot find -lmx
collect2: ld returnerede afslutningskoden 1
makefile:8: recipe for target `RKspace2d' failed
make: *** [RKspace2d] Error 1
I believe the path is correct since both libeng.lib and libmx.lib are contained in the microsoft folder.
Hope you guys can help
Thomas