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

Failing to compile sample project #35

Closed
somegituser123 opened this issue Oct 6, 2020 · 3 comments
Closed

Failing to compile sample project #35

somegituser123 opened this issue Oct 6, 2020 · 3 comments
Labels
question Further information is requested

Comments

@somegituser123
Copy link

Using Win10, VS2019.

First, I followed the instructions and compiled Lava + external dependencies w/ Cmake and VS2019 in Debug x64 mode. Everything compiled successfully. Then, I created a new separate project, and added all the includes and libraries in the exact order specified in the lava tests project.

lava.app.lib
lava.frame.lib
lava.resource.lib
glfw3.lib
lava.block.lib
lava.base.lib
lava.util.lib
lava.core.lib
physfs-static.lib
spdlogd.lib

Tutorial Code

#include <liblava/lava.hpp>
using namespace lava;

int main(int argc, char* argv[]) {

    lava::frame frame({ argc, argv });
    if (!frame.ready())
        return error::not_ready;

    auto count = 0;

    frame.add_run([&]() {
        sleep(seconds(1));
        count++;

        log()->debug("{} - running {} sec", count, to_sec(frame.get_running_time()));

        if (count == 3)
            frame.shut_down();

        return true;
        });

    return frame.run();
}

Then, I got a bunch of errors when building. Some issue w/ linking spdlogd.

1>spdlogd.lib(fmt.obj) : error LNK2005: "void __cdecl fmt::v7::detail::assert_fail(char const *,int,char const *)" (?assert_fail@detail@v7@fmt@@YAXPEBDH0@Z) already defined in tutorial.obj
1>spdlogd.lib(fmt.obj) : error LNK2005: "public: void __cdecl fmt::v7::detail::error_handler::on_error(char const *)" (?on_error@error_handler@detail@v7@fmt@@QEAAXPEBD@Z) already defined in tutorial.obj
1>spdlogd.lib(fmt.obj) : error LNK2005: "public: virtual __cdecl fmt::v7::format_error::~format_error(void)" (??1format_error@v7@fmt@@UEAA@XZ) already defined in tutorial.obj
1>spdlogd.lib(fmt.obj) : error LNK2005: "void __cdecl fmt::v7::detail::format_error_code(class fmt::v7::detail::buffer<char> &,int,class fmt::v7::basic_string_view<char>)" (?format_error_code@detail@v7@fmt@@YAXAEAV?$buffer@D@123@HV?$basic_string_view@D@23@@Z) already defined in tutorial.obj
1>spdlogd.lib(fmt.obj) : error LNK2005: "void __cdecl fmt::v7::format_system_error(class fmt::v7::detail::buffer<char> &,int,class fmt::v7::basic_string_view<char>)" (?format_system_error@v7@fmt@@YAXAEAV?$buffer@D@detail@12@HV?$basic_string_view@D@12@@Z) already defined in tutorial.obj
1>spdlogd.lib(fmt.obj) : error LNK2005: "int __cdecl fmt::v7::detail::safe_strerror(int,char * &,unsigned __int64)" (?safe_strerror@detail@v7@fmt@@YAHHAEAPEAD_K@Z) already defined in tutorial.obj
1>spdlogd.lib(spdlog.obj) : error LNK2005: "class fmt::v7::basic_string_view<char> & __cdecl spdlog::level::to_string_view(enum spdlog::level::level_enum)" (?to_string_view@level@spdlog@@YAAEAV?$basic_string_view@D@v7@fmt@@W4level_enum@12@@Z) already defined in tutorial.obj
1>spdlogd.lib(spdlog.obj) : error LNK2005: "char const * __cdecl spdlog::level::to_short_c_str(enum spdlog::level::level_enum)" (?to_short_c_str@level@spdlog@@YAPEBDW4level_enum@12@@Z) already defined in tutorial.obj
1>spdlogd.lib(spdlog.obj) : error LNK2005: "public: __cdecl spdlog::spdlog_ex::spdlog_ex(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (??0spdlog_ex@spdlog@@QEAA@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) already defined in tutorial.obj
1>spdlogd.lib(spdlog.obj) : error LNK2005: "public: __cdecl spdlog::spdlog_ex::spdlog_ex(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,int)" (??0spdlog_ex@spdlog@@QEAA@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@H@Z) already defined in tutorial.obj
1>spdlogd.lib(spdlog.obj) : error LNK2005: "public: virtual char const * __cdecl spdlog::spdlog_ex::what(void)const " (?what@spdlog_ex@spdlog@@UEBAPEBDXZ) already defined in tutorial.obj
@pezcode
Copy link
Contributor

pezcode commented Oct 6, 2020

Try defining SPDLOG_COMPILED_LIB in your project somewhere. I'm guessing without that define it goes into header-only mode and redefines a bunch of stuff that was previously compiled into spdlog.lib

I'd recommend using CMake to generate your project as well, because it sets up the correct includes, libraries and preprocessor/compiler definitions. You can also do that with a precompiled lava version, it's described here.

@TheLavaBlock
Copy link
Member

TheLavaBlock commented Oct 6, 2020

pezcode was a few seconds faster before I press "Comment" 😉

Additionally I would recommend you to have a look into the template.
As described in the readme you can easily clone it, rename it and use it for your project.

@TheLavaBlock TheLavaBlock added the question Further information is requested label Oct 6, 2020
@somegituser123
Copy link
Author

@pezcode - thanks, your solution works perfectly!

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

No branches or pull requests

3 participants