Groups
Sign in
Groups
pl.comp.os.linux.programowanie
Conversations
About
Send feedback
Help
info
Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss
Learn more
C++ opcja -E
8 views
Skip to first unread message
RM
unread,
Aug 1, 2020, 2:28:56 AM
8/1/20
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Sign in to report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to
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.
RM
unread,
Aug 1, 2020, 6:42:09 AM
8/1/20
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Sign in to report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to
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.
0 new messages