0

I'm using the code of this this tutorial to link a simple main function with the filament library.

The folder structure is:

|-- README.md
|-- bin
|-- docs
|-- include
|-- lib
|-- main.cpp

And I've unrolled the contento the makefile as follow:

/usr/bin/clang-cpp-8 main.cpp -L./lib/x86_64/ -I./include -lfilament -lbluegl -lbluevk -lfilabridge -lfilaflat -lutils -lpthread -lc++ -ldl -lm -std=c++14 -pthread -c

But when I run that line, or the original makefile I get:

clang: warning: -lfilament: 'linker' input unused in cpp mode [-Wunused-command-line-argument]
clang: warning: -lbluegl: 'linker' input unused in cpp mode [-Wunused-command-line-argument]
clang: warning: -lbluevk: 'linker' input unused in cpp mode [-Wunused-command-line-argument]
clang: warning: -lfilabridge: 'linker' input unused in cpp mode [-Wunused-command-line-argument]
clang: warning: -lfilaflat: 'linker' input unused in cpp mode [-Wunused-command-line-argument]
clang: warning: -lutils: 'linker' input unused in cpp mode [-Wunused-command-line-argument]
clang: warning: -lpthread: 'linker' input unused in cpp mode [-Wunused-command-line-argument]
clang: warning: -lc++: 'linker' input unused in cpp mode [-Wunused-command-line-argument]
clang: warning: -ldl: 'linker' input unused in cpp mode [-Wunused-command-line-argument]
clang: warning: -lm: 'linker' input unused in cpp mode [-Wunused-command-line-argument]
clang: warning: argument unused during compilation: '-L./lib/x86_64/' [-Wunused-command-line-argument]

plus for some reason the following output (Only partial because is too long)

# 1 "main.cpp"
# 1 "<built-in>" 1
# 1 "<built-in>" 3
# 389 "<built-in>" 3
# 1 "<command line>" 1
# 1 "<built-in>" 2
# 1 "main.cpp" 2
# 1 "./include/filament/FilamentAPI.h" 1
# 20 "./include/filament/FilamentAPI.h"
# 1 "./include/utils/compiler.h" 1
# 21 "./include/filament/FilamentAPI.h" 2

# 1 "/usr/include/clang/8.0.0/include/stddef.h" 1 3
# 51 "/usr/include/clang/8.0.0/include/stddef.h" 3
typedef long int ptrdiff_t;
# 62 "/usr/include/clang/8.0.0/include/stddef.h" 3
typedef long unsigned int size_t;
# 118 "/usr/include/clang/8.0.0/include/stddef.h" 3
# 1 "/usr/include/clang/8.0.0/include/__stddef_max_align_t.h" 1 3
# 35 "/usr/include/clang/8.0.0/include/__stddef_max_align_t.h" 3
typedef struct {
  long long __clang_max_align_nonce1
      __attribute__((__aligned__(__alignof__(long long))));
  long double __clang_max_align_nonce2
      __attribute__((__aligned__(__alignof__(long double))));
} max_align_t;
# 119 "/usr/include/clang/8.0.0/include/stddef.h" 2 3
# 23 "./include/filament/FilamentAPI.h" 2

namespace filament {







class __attribute__((visibility("default"))) FilamentAPI {
protected:

    FilamentAPI() noexcept = default;
    ~FilamentAPI() = default;

There's no much indication of what the error could be, can anyone help?

For reference the Makefile:

FILAMENT_LIBS=-lfilament -lbluegl -lbluevk -lfilabridge -lfilaflat -lutils
CC=clang++

main: main.o
    $(CC) -Llib/x86_64/ main.o $(FILAMENT_LIBS) -lpthread -lc++ -ldl -o main

main.o: main.cpp
    $(CC) -Iinclude/ -std=c++14 -pthread -c main.cpp

clean:
    rm -f main main.o

.PHONY: clean
user8469759
  • 2,522
  • 6
  • 26
  • 50
  • You command compiles code, e.g. produces an `.o` file. This is what happens when `-c` flag is passed to compiler. Linker is not used at this step and you got such warnings. – Eugene Kosov Mar 04 '19 at 16:32
  • But isn't the make file supposed to produce an executable? As far as I can see it should, but it doesn't. Are you saying the warnings are normal then? – user8469759 Mar 04 '19 at 16:34
  • Makefile runs commands which create targets like `main` and `main.o` in your case. > And I've unrolled the contento the makefile as follow: How did you do this? Mostly curios. https://stackoverflow.com/questions/5820303/how-do-i-force-make-gcc-to-show-me-the-commands You probably just run your original command without `-c` flag and in a good case command will produce executable named `a.out`. – Eugene Kosov Mar 04 '19 at 16:44
  • Literally I've substituted the variables and run as a single command. I didn't spot the `-c` flag, but anyway... As I said using the makefile doesn't make any difference. There's no executable produced. And I'm trying to figure why... – user8469759 Mar 04 '19 at 16:46
  • Also if in the makefile I comment `main: main.o $(CC) -L./lib/x86_64/ main.o $(FILAMENT_LIBS) -lpthread -lc++ -ldl -lm -o main ` and I only leave `main.o: main.cpp $(CC) -I./include/ -std=c++14 -pthread -c main.cpp` no `main.o` is produced. – user8469759 Mar 04 '19 at 16:49
  • Where did you get `/usr/bin/clang-cpp-8 main.cpp -L./lib/x86_64/ -I./include -lfilament -lbluegl -lbluevk -lfilabridge -lfilaflat -lutils -lpthread -lc++ -ldl -lm -std=c++14 -pthread -c` from? There's nothing like that in the Makefile. – melpomene Mar 04 '19 at 16:50
  • Just combining the two lines into one and substituting `$(CC)` with my location of `clang` – user8469759 Mar 04 '19 at 16:53
  • The other output looks like the result of preprocessing, which is normally what you get with `clang++ -P` (or by running `cpp` directly). – melpomene Mar 04 '19 at 16:54
  • As far as I can tell, this is all user error. The Makefile is fine; you're just running the wrong command (the preprocessor instead of the compiler) with the wrong arguments (passing both `-L` / `-l` and `-c`). – melpomene Mar 04 '19 at 16:56
  • @melpomene ok I agree the line is wrong, but why when I use the makefile instead (literally with `>make`) no output is produced? I understand now that the generation of `main.o` has nothing to do with linking, but no `main.o` is generated which implies no final output is generated. – user8469759 Mar 04 '19 at 16:58
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/189405/discussion-between-melpomene-and-user8469759). – melpomene Mar 04 '19 at 16:58

0 Answers0