billyquith / ponder

C++ reflection library with Lua binding, and JSON and XML serialisation.
http://billyquith.github.io/ponder/
Other
647 stars 95 forks source link

Unresolved externals #2

Closed NickCullen closed 8 years ago

NickCullen commented 8 years ago

Hey, I compiled ponder with MSVC2015 (generated project using the CMAKE file provided).

In my project I set up the usual library linking paths and included ponder.lib and followed the code from the example code provided but I am getting unresolved external symbols (crazy big errors from VS). I'm fairly certain I have linked correctly (checked this over and over) but it doesn't seem to be linking.

Could this be a build issue?

Image of the errors: https://gyazo.com/29f2253c683a50b704c388afaa6b972d

Class header file: https://gyazo.com/95f69c5bce8fce24b45d11f9622b568c Class source file: https://gyazo.com/a591b22d2312e1936b81f4d40257a40e Main : https://gyazo.com/c9b11549ce0de44a72dc77f79ab9c53e

I've tried various things even included all the headers into my project incase their was some inline methods that were needed but still couldn't get it work.

Really want to use this library, I have been looking for a few days for a nice c++ reflection library and this seems perfect for my needs :)

billyquith commented 8 years ago

Thanks for the feedback. I did have a couple of issues with MSVC 2015 and Boost unit testing, so swapped to Catch. Haven't really tested on Windows since. Easter this weekend, hopefully get to this on Tuesday. Will try and get CI working for Windows.

NickCullen commented 8 years ago

Thanks for the reply, I had to include the source into my projects DLL and it seems to be working. Still cant link Ponder via the DLL & .lib built from the CMake project provided though.

Another issue I have is declaring a base class which is a templated class. For example, I have a singleton base class which takes derived types via a templated parameter. Are template classes supported in Ponder?

Example code: Singleton Class: https://gyazo.com/5cb9454984e5b0bce527641ce53b8e64 Derived class (Engine): https://gyazo.com/1396258a395daf34578b96f42b2b4e8f Register function: https://gyazo.com/a7b0395b3b87cbf3f3ff41bf7d41d9a8

Error: https://gyazo.com/c3b5c53b101ee4dc11fa5d989aa16954

If this is a bug in Ponder and you want me to post as a seprate issue I will be happy to do so. Although it's most likely down to me miss-using the system. Any help would be greatly appreciated :)

Happy Easter!

NickCullen commented 8 years ago

Found the reason why it was incorrectly setting the base class of VEngine to VEngine (when it should be VSingleton was due to line 50 in classbuilder.inl

const Class& baseClass = classByType<U>();

Down the call tree of classByType it referes to U via RawPointer which seems to strip away VSingleton<> and just uses the VEngine type.

Managed to work around this by swapping the line to

classByName(detail::StaticTypeId<U>::get(false))

Still cant declare any properties/functions/constructors for the Sinlgeton class though. (Which is what the error in the previous message was for).

billyquith commented 8 years ago

For future reference, you can just paste code samples into the issues here and format using markdown, e.g.

int main() { return 0; }

Or you can use Gist. Just makes it easier to copy when testing. You can also attach screenshots directly.

NickCullen commented 8 years ago

Thanks for letting me know, first issue I had posted sorry about that!

billyquith commented 8 years ago

I think the first linking error is fixed. That is due to the default build being a shared library, i.e. a DLL, and those symbols weren't exported from the ponder library. Should be fixed in Master now.

billyquith commented 8 years ago

If this is a bug in Ponder and you want me to post as a seprate issue I will be happy to do so. Although it's most likely down to me miss-using the system. Any help would be greatly appreciated :)

Yes, it is much easier to report each issue separately otherwise it is confusing having multiple threads of discussion going on! I'll try and get to the other issue soon, but might be next week now. I am busy with other things this week. You should be able to link the project. If not in CMakeCache.txt set:

//TRUE to build Ponder as a shared library, FALSE to build it as
// a static library.
BUILD_SHARED_LIBS:BOOL=FALSE
billyquith commented 8 years ago

I'll close this issue. If you have any further problems please report with details.