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

multiple definition of sqlite::database_binder' #15

Closed
adnan-emd opened this issue Nov 16, 2015 · 6 comments
Closed

multiple definition of sqlite::database_binder' #15

adnan-emd opened this issue Nov 16, 2015 · 6 comments

Comments

@adnan-emd
Copy link

Adding "#include <sqlite_modern_cpp.h>" multiple .cpp files causes multiple definition errors.
This is on 64-bit Kubuntu 15.04 using Netbeans 8.02. Compile errors are attached.

compile_errors.txt

@edrosten
Copy link
Collaborator

Should be fixed now. Please reopen if the problem persists.

@adnan-emd
Copy link
Author

Thanks for the fix and thanks for the great library, Edward!

@MordechaiMaman
Copy link
Contributor

hi I saw that you fixed this issue (commit) so I'm not sure when exactly that happen but I'm having the same issue again..
if you could take a look at the functions:

template<> database_binder::chain_type& operator <<(database_binder::chain_type& db, const std::string& txt) 
template<> void get_col_from_db(database_binder& db, int inx, std::u16string & w) 
template <typename BoostOptionalT> database_binder::chain_type& operator <<(database_binder::chain_type& db, const boost::optional<BoostOptionalT>& val) 
template <typename BoostOptionalT> void get_col_from_db(database_binder& db, int inx, boost::optional<BoostOptionalT>& o) 
void operator++(database_binder::chain_type& db, int)

at lines 467, 477, 498, 511 and 527
that would be great !

@Killili
Copy link
Collaborator

Killili commented Mar 15, 2016

Hi,
sorry but a bit more information is needed here.
What is actually going wrong? On which compiler? Under what circumstances? Are you using boost optional?...

@MordechaiMaman
Copy link
Contributor

right sorry...
the same issue of redefine for some symbols caused by two include of the main header from two different obj files.
I'm using vc 2015 in the default settings when I got all the header paths and library right (these and boost)
and it doesn't matter if I'm using boost optional or not this is still happening...

SqlMannager.obj : error LNK2005: "class std::unique_ptr<class sqlite::database_binder,struct std::default_delete<class sqlite::database_binder> > & __cdecl sqlite::operator<<<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >(class std::unique_ptr<class sqlite::database_binder,struct std::default_delete<class sqlite::database_binder> > &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (??$?6V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@sqlite@@YAAAV?$unique_ptr@Vdatabase_binder@sqlite@@U?$default_delete@Vdatabase_binder@sqlite@@@std@@@std@@AAV12@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@@Z) already defined in main.obj
SqlMannager.obj : error LNK2005: "void __cdecl sqlite::get_col_from_db<class std::basic_string<char16_t,struct std::char_traits<char16_t>,class std::allocator<char16_t> > >(class sqlite::database_binder &,int,class std::basic_string<char16_t,struct std::char_traits<char16_t>,class std::allocator<char16_t> > &)" (??$get_col_from_db@V?$basic_string@_SU?$char_traits@_S@std@@V?$allocator@_S@2@@std@@@sqlite@@YAXAAVdatabase_binder@0@HAAV?$basic_string@_SU?$char_traits@_S@std@@V?$allocator@_S@2@@std@@@Z) already defined in main.obj
SqlMannager.obj : error LNK2005: "void __cdecl sqlite::operator++(class std::unique_ptr<class sqlite::database_binder,struct std::default_delete<class sqlite::database_binder> > &,int)" (??Esqlite@@YAXAAV?$unique_ptr@Vdatabase_binder@sqlite@@U?$default_delete@Vdatabase_binder@sqlite@@@std@@@std@@H@Z) already defined in main.obj
D:\Projects\Magshimim\guardroid\server\GuardroidServer\Debug\GuardroidServer.exe : fatal error LNK1169: one or more multiply defined symbols found

just to let you know - adding inline keyword to the functions I mentioned above solves the problem...

@Killili
Copy link
Collaborator

Killili commented Mar 16, 2016

Ok if you know the solution, make a pull request and i merge it.
Sounds ok to me, a few inlines more make the resulting binary bigger but might be the easiest fix for this, apart from battling the template parser for a few hours....

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

4 participants