First I should say that I am far from a C++ ninja, and I've only compiled a
few simple things with emscripten thus far.
So I have my main.cpp file, and a class called Foo in Foo.h and Foo.cpp.
main.cpp includes Foo.h and Foo.cpp includes Foo.h, but when I compile, I
get the error: "warning: unresolved symbol: _ZN5FooC1EV". My understanding
was that this was the standard way of doing things in C++. *However, *when
I switch the contents of Foo.h and Foo.cpp to a function declaration and
implementation, respectively, I get no such error. When I change the
contents of my Makefile from "emcc -g4 src/main.cpp -o out/main.js" to
"emcc -g4 src/main.cpp src/Foo.cpp -o out/main.js", everything works. This
makes sense to me, since Foo.cpp is not actually getting *included *anywhere
in the code. But what confuses me is that all the emscripten examples I
have read do not seem to do this, and code like this works with
cl(Microsoft's C++ compiler).
Did I miss something here? Am I making a dumb mistake? Any help is
appreciated.(below is posted my code)
Main.cpp:
#include <iostream>
#include <stdio.h>
#include "Foo.h"
int main(int argc, char const *argv[])
{
Foo f;
printf("%i\n", f.bar);
return 0;
}
Foo.h:
#ifndef FOOH
#define FOOH
#pragma once
class Foo
{
public:
Foo();
~Foo();
int bar;
};
#endif
Foo.cpp:
#include "Foo.h"
Foo::Foo()
{
printf("Hello\n");
bar = 12;
}
Foo::~Foo()
{
}
Makefile:
emcc -g4 src/main.cpp src/Foo.cpp -o out/main.js
--
You received this message because you are subscribed to the Google Groups
"emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.