Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Following startup guide throws Linker errors #150

Closed
vcbnm opened this issue Jun 18, 2021 · 9 comments
Closed

Following startup guide throws Linker errors #150

vcbnm opened this issue Jun 18, 2021 · 9 comments

Comments

@vcbnm
Copy link

vcbnm commented Jun 18, 2021

I've followed the setup instructions on the Getting started page, using the crow_all.h from release 0.3. I'm trying to integrate Crow into an existing project but I've also tried using a clean project.

The following errors occur:

LNK2001	unresolved external symbol "public: static int crow::detail::dumb_timer_queue::tick" (?tick@dumb_timer_queue@detail@crow@@2HA)

LNK2001	unresolved external symbol "class std::unordered_map<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,struct std::hash<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >,struct std::equal_to<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >,class std::allocator<struct std::pair<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const ,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > > > crow::mime_types" (?mime_types@crow@@3V?$unordered_map@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@U?$hash@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@U?$equal_to@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@V?$allocator@U?$pair@$$CBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@@std@@@2@@std@@A)

I'm using VS2019 and I followed the instructions, using the vcpkg.json to retrieve the dependencies. I've also tried an empty project but it still throws the same LNK2001 exceptions. Other things I have tried are; using nuget and manually setting Linker directories and dependencies, placing the dll's next to the executable, using crow.h and other files instead of crow_all.h, use VS2017 with the same instructions.

Regardless of how I approach it, these are the errors I end up with. My C++ skills are a bit rusty, am I overlooking something?

@The-EDev
Copy link
Member

The-EDev commented Jun 18, 2021

Could you please show your code? or are you using the example's code?

@vcbnm
Copy link
Author

vcbnm commented Jun 18, 2021

Could you please show your code? or are you using the example's code?

I'm using the Hello World example.

@The-EDev
Copy link
Member

You issue is most likely caused by a missing #define CROW_MAIN, I ran everything fresh and got no error, I got the same linker errors when I deleted the macro.

@The-EDev
Copy link
Member

The-EDev commented Jun 18, 2021

Please let me know if adding #define CROW_MAIN fixes the issue

@vcbnm
Copy link
Author

vcbnm commented Jun 23, 2021

I fixed the issue. #define CROW_MAIN wasn't missing in my case but for some reason the define and include were switched around. Using the macro before including the header removed the errors.

@JakeInit
Copy link

I also just recently ran into this issue. I had built the header using cmake from the instructions and was just trying to implement the json example. Adding "#define CROW_MAIN before the header fixed the issue. A frequently asked questions section in the README.md may help users quickly fix these types of issues and prevent any duplicate issues from being created. Can't guarantee everyone will read the documentation, but I only found this out by checking the issues section after reading the doc and seeing nothing on this.

Also, this did not prevent building, but to avoid the cmake message "Not found TcMalloc", I had to do the following:

sudo apt-get install google-perftools
sudo apt-get install libgoogle-perftools-dev
sudo ln -s /usr/lib/x86_64-linux-gnu/libtcmalloc.so /usr/lib/libtcmalloc.so

@vcbnm
Copy link
Author

vcbnm commented Jun 28, 2021

I noticed the Hello World example in the ReadMe was missing the #define CROW_MAIN, adding it there as well might prevent these issues from being reported. Since it's presented as a working implementation, people like myself might be inclined to directly implement this version instead of the example hidden deeper into the documentation.

@The-EDev
Copy link
Member

@JakeInit I'll make sure to make ti more clear that crow macros need to be always before the #include. I have also been thinking about an FAQ for some time, I just don't have enough questions..

As for tcmalloc, it is optional and if available then crow will utilize it. Although I wouldn't advise anyone to use any tools developed by Google.

@The-EDev
Copy link
Member

@vcbnm This is absolutely my fault, I corrected the "Your First Application" section in the documentation but forgot to correct the readme. Thanks a lot for letting me know, I'll fix it immediately.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants