Thread View: pl.comp.os.linux.programowanie
2 messages
2 total messages
Started by RM
Sat, 01 Aug 2020 06:28
C++ opcja -E
Author: RM
Date: Sat, 01 Aug 2020 06:28
Date: Sat, 01 Aug 2020 06:28
101 lines
4044 bytes
4044 bytes
Piszę program w C++. Potrzebuję zmodyfikować tak Makefile, żeby zostały wygenerowane pliki .i - tzn. chcę użyć opcji -E. Oto mój Makefile: #ifeq ($(ARCH),win32) ## Windows with the VC++ compiler #ObjSuf = obj #SrcSuf = cxx #ExeSuf = .exe #DllSuf = dll #OutPutOpt = -out: #CXX = cl #CXXOPT = -O2 #CXXOPT = -Z7 #CXXFLAGS = $(CXXOPT) -G5 -GR -GX -MD -DWIN32 -D_WINDOWS -nologo \ # -DVISUAL_CPLUSPLUS -D_X86_=1 -D_DLL #LD = link #LDOPT = -opt:ref #LDOPT = -debug #LDFLAGS = $(LDOPT) -pdb:none -nologo #SOFLAGS = -DLL CXX := -c++ # gcc czy g++? CXXFLAGS := -Wall -Wextra -Werror -no-pie # -pedantic-errors; add "-no-pie" to the CMAKE_CXX_FLAGS LDFLAGS := -L/usr/lib -lstdc++ -lstdc++fs -lm # -Lsrc/boost_1_65_0/lib/ -lboost_regex-gcc34-mt-d-1_3 BUILD := ./build OBJ_DIR := $(BUILD)/objects APP_DIR := $(BUILD)/apps TARGET := dirtyphp INCLUDE := -Iinclude/ # -I src/boost_1_65_0 SRC := $(wildcard src/*.cpp) OBJECTS := $(SRC:%.cpp=$(OBJ_DIR)/%.o) all: build $(APP_DIR)/$(TARGET) $(OBJ_DIR)/%.o: %.cpp @mkdir -p $(@D) $(CXX) $(CXXFLAGS) $(INCLUDE) -E -c $< -o $@ $(LDFLAGS) >$(OBJ_DIR)/%.i $(APP_DIR)/$(TARGET): $(OBJECTS) @mkdir -p $(@D) $(CXX) $(CXXFLAGS) -o $(APP_DIR)/$(TARGET) $^ $(LDFLAGS) .PHONY: all build clean debug release build: @mkdir -p $(APP_DIR) @mkdir -p $(OBJ_DIR) debug: CXXFLAGS += -DDEBUG -g debug: all test: CXXFLAGS += -pg # dodałem dynamic execution profiler test: all release: CXXFLAGS += -O2 release: all # production clean: -@rm -rvf $(OBJ_DIR)/* -@rm -rvf $(APP_DIR)/* Próbowałem tak: zmieniłem sekcję: $(OBJ_DIR)/%.o: %.cpp @mkdir -p $(@D) $(CXX) $(CXXFLAGS) $(INCLUDE) -c $< -o $@ $(LDFLAGS) w następujący sposób: $(OBJ_DIR)/%.o: %.cpp @mkdir -p $(@D) $(CXX) $(CXXFLAGS) $(INCLUDE) -E -c $< -o $@ $(LDFLAGS) >$(OBJ_DIR)/%.i Niestety kompilacja się nie udaje: c++ -Wall -Wextra -Werror -no-pie -DDEBUG -g -Iinclude/ -E -c src/dirtyphp.cpp -o build/objects/src/dirtyphp.o -L/usr/lib -lstdc++ -lstdc++fs -lm >./build/objects/%.i c++ -Wall -Wextra -Werror -no-pie -DDEBUG -g -Iinclude/ -E -c src/common.cpp -o build/objects/src/common.o -L/usr/lib -lstdc++ -lstdc++fs -lm >./build/objects/%.i c++ -Wall -Wextra -Werror -no-pie -DDEBUG -g -Iinclude/ -E -c src/source_file.cpp -o build/objects/src/source_file.o -L/usr/lib -lstdc++ -lstdc++fs -lm >./build/objects/%.i c++ -Wall -Wextra -Werror -no-pie -DDEBUG -g -Iinclude/ -E -c src/obfuscator.cpp -o build/objects/src/obfuscator.o -L/usr/lib -lstdc++ -lstdc++fs -lm >./build/objects/%.i c++ -Wall -Wextra -Werror -no-pie -DDEBUG -g -o ./build/apps/dirtyphp build/objects/src/dirtyphp.o build/objects/src/common.o build/objects/src/source_file.o build/objects/src/obfuscator.o -L/usr/lib -lstdc++ -lstdc++fs -lm build/objects/src/dirtyphp.o: file not recognized: Nieznany format pliku collect2: error: ld returned 1 exit status Makefile:38: recipe for target 'build/apps/dirtyphp' failed make: [build/apps/dirtyphp] Error 1 (zignorowano) Proszę o pomoc.
Re: C++ opcja -E
Author: RM
Date: Sat, 01 Aug 2020 10:42
Date: Sat, 01 Aug 2020 10:42
7 lines
1130 bytes
1130 bytes
Jakoś poradziłem sobie kompilując potrzebny plik z wiersza poleceń komendą: c++ -Wall -Wextra -Werror -no-pie -Iinclude/ -E -c dirtyphp.cpp -L/usr/lib -lstdc++ -lstdc++fs -lm >dirtyphp.i Jeden plik dirtyphp.i mi wystarczy. Problem zamknięty.
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads