[SOLVED] MSVS 2010 linker error LNK2019 while using ui components (ui::ScrollView)

Hi,

So I made a project with cocos console tool, v3.2.

Now I want to add a few ui elements (ScrollView, Button, etc…) to a layer…

So I added #include "ui/UIScrollView.h" at the top and later on instantiate it auto scrollView = ui::ScrollView::create();

But it doesn’t compile (win32 proj with msvs 2010), failing at the linkage:

Error	5	error LNK2019: unresolved external symbol "public: static class cocos2d::ui::ScrollView * __cdecl cocos2d::ui::ScrollView::create(void)" (?create@ScrollView@ui@cocos2d@@SAPAV123@XZ) referenced in function "public: virtual bool __thiscall MainMenu::init(void)" (?init@MainMenu@@UAE_NXZ)	C:\Projects\Kamebu\proj.win32\MainMenu.obj
Error	6	error LNK2019: unresolved external symbol "public: void __thiscall cocos2d::ui::ScrollView::setBounceEnabled(bool)" (?setBounceEnabled@ScrollView@ui@cocos2d@@QAEX_N@Z) referenced in function "public: virtual bool __thiscall MainMenu::init(void)" (?init@MainMenu@@UAE_NXZ)	C:\Projects\Kamebu\proj.win32\MainMenu.obj

Why is it happening?..
Maybe newly created project with cocos tool doesn’t have a ui components wired by default? Is it ok to use ui components for a cross-platform development or maybe there is some other hidden obstacles to be considered?

Regards,
Mike.

Can some one please check on msvs 2010 if it compiles?

It seems very strange that it’s complaining about unresolved symbol, but intelisense works ok…

This thread might help you:

ui button code

1 Like

@utilae Big thanks, it helped!

After I added libExtensions and libGUI projects to my solution, wired all references, dependencies and added in my source #include "ui/CocosGUI.h" it seems to work! :smiley:

I have left one more question, are the libGUI components fully cross-platform or there is some limitations?

Never include the headers of the individual components. Always add the global header file, as it includes all the individual headers of the components.

You don’t need to add the projects, just link them. unresolved external symbol is a Linker error, which means, that you missed linking a library against your app/game binary.

They all are fully cross-platform and there are no limitations. The GUI components don’t call the native components on each platform.

1 Like

@iQD big thanks for your help!

@iQD @utilae can you guys look here please: [SOLVED] Proj.android build error, undefined reference to ui component (ScrollView)?

It’s the same one, but now I’m trying to build it for android.