How do I link a different project in the same solution?

I have an OpenGL game ("engine") project and I want to build a separate Editor project inside the same solution.
The Editor project needs access to classes inside the OpenGL project(in this example I'm trying to access the Debug class), so inside the Editor project I added a reference to the OpenGL project.

The IDE doesn't complain when importing the Debug class, but at compile time the Linker throw:
0>Editor.obj: Error LNK2019 : unresolved external symbol "public: static void __cdecl Debug::Log(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?Log@Debug@@SAXAEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) referenced in function main
0>Editor.exe: Error LNK1120 fatal: 1 unresolved externals
0>------- Finished building project: Editor. Succeeded: False. Errors: 2. Warnings: 1

What else do I need to modify? 



Also, an extra question, where can I learn how to structure different imports etc… for a project like this?
I've started really learning cpp recently (coded c# and TS for some years) and I understand the coding concepts, but anytime I need to do something “meta” like adding libraries/linking code it feels extremely inconsistent and random.
E.g. some libraries are header only/ some other you need to add include libraries but not link a .lib file, some other you need to copy a .dll. 

0
4 comments

Hello Nevio,

Thank you for contacting Rider support.

It it totally understandable, that such difficulties are encountered by a developers who are new to C++ development.

This error means that the referenced method implementation was not found among libraries that a project reference.

To narrow down where is the issue, would you mind sharing your project with me? So that I'll identify where is the issue and provide a solution.

Meanwhile, you might find these articles helpful. It walks you through the process of creating and configuring C++ libraries

If sharing a project is not possible, you can verify the following settings for the project that needs the access to the source code in another project:

Have a nice day!

0

Forgot to add, you can upload your solution to the Upload service and let me know the Upload ID, so that I can access it.

Note: your upload will only be available to JB employees.

0

Thank you Dmitry Kazantsev , I really appreciate the help and the links were helpful :)

I was able to solve the issue by changing the configuration type of the OpenGLProject(the engine part) from .exe to .lib

and then adding ./x64/Debug to the additional library dependencies.

I guess I didn't realize what I need is to actually use the compiled engine (.lib) instead of plain source code.

As I'm working at both engine and editor at the same time I'll have to be more attentive when making changes to the engine so that I don't break the editor, but shouldn't be a big issue.

Thanks you, take care


 

0
Hello Nevio,

Thank you for keeping me posted! I am glad to hear that I was able to help.
If there are no other questions, then I am going to proceed with archiving this ticket.
Should you have any other questions or difficulties in the future, do not hesitate to contact support.

Have a nice day!
1

Please sign in to leave a comment.