Note that there are some explanatory texts on larger screens.

plurals
  1. POMakefile problems with gcc flags (file not recognized; shared libraries)
    primarykey
    data
    text
    <p>I'm a little confused now. I'm trying to get the Makefile work but it breaks. I Hope someone can help me with this bad and frustrating time-killer.</p> <p>I've written a small and lightweight part of a Compiler.</p> <blockquote> <p><strong>The project has the following structure:</strong> </p> <p>/Compiler.cpp<br> /Makefile<br> /Buffer/<br> /Buffer/Makefile<br> /Scanner/<br> /Scanner/Makefile<br> /SymTable/<br> /SymTable/Makefile </p> </blockquote> <p>When I'm compiling Buffer, Scanner and SymTable manual (changing the directory and typing 'make mode=release' it's no problem and each shared-library is compiled). But when I run the Makefile from within where the 'Master Makefile' /Makefile is, it fails and the terminal prints something like: </p> <pre><code>Buffer/libBuffer.so: file not recognized: File format not recognized collect2: ld returned 1 exit status make: \*** [Compiler] Error 1 </code></pre> <p>Here is the listing of the Makefile of /Buffer/Makefile (the same for Scanner and SymTable):</p> <pre><code>CXX = g++ ifeq ($(mode),release) CXXFLAGS = -g -fPIC -O3 -ffunction-sections -march=native else mode = debug CXXFLAGS = -g3 endif MODUL = Buffer COMPONENTS = Buffer.h MK_LIBRARY = lib$(MODUL).so all: $(MK_LIBRARY) $(MK_LIBRARY): $(COMPONENTS) $(CXX) $(CXXFLAGS) -shared -o $@ $^ clean: rm -f $(MK_LIBRARY) .PHONY: all .PHONY: clean </code></pre> <p>The 'Master Makefile' looks like: CXX = g++</p> <pre><code>ifeq ($(mode),release) CXXFLAGS = -g -O3 -ffunction-sections -fwhole-program -march=native else mode = debug CXXFLAGS = -g3 endif TARGET = Compiler COMPONENTS = $(TARGET) DIRS = Buffer Scanner SymTable MAKE = make MFLAGS = mode=$(mode) all: $(COMPONENTS) $(TARGET): Compiler.cpp libBuffer.so libScanner.so libSymTable.so $(CXX) $(CXXFLAGS) -IBuffer -IScanner -ISymTable \ -LBuffer -LScanner -LSymTable \ -lBuffer -lScanner -lSymTable -o $@ Compiler.cpp libBuffer.so: force_look cd Buffer; $(MAKE) $(MFLAGS) libScanner.so: force_look cd Scanner; $(MAKE) $(MFLAGS) libSymTable.so: force_look cd SymTable; $(MAKE) $(MFLAGS) clean: rm -f $(COMPONENTS) @for d in $(DIRS); do (cd $$d; $(MAKE) clean ); done check: @for d in $(DIRS); do (cd $$d; $(MAKE) check ); done force_look: true .PHONY: all .PHONY: clean .PHONY: check </code></pre> <p>I hope some has an answer for me! Thanks!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload