Error while linking client code to Boost.Filesystem library on windows 7 platform, while developing a FB NPAPI plugin (link error LNK2019)

1,066 views
Skip to first unread message

Ajay Prabandham

unread,
Sep 2, 2013, 7:20:57 AM9/2/13
to firebre...@googlegroups.com, Soumen Basak, dutta....@gmail.com
Dear Group,
                      My apologies for my rather long post with a lot of non-lingual junk thrown in :-). 

While developing a NPAPI plugin to access filesystem properties and pathnames, I was referring to Boost documentation and repeating a routine (available on the web) to check if a file exists in a filesystem and returning the pathname if found. I am using Boost Filesystem Library for this purpose, keeping the larger picture of portability in mind. The code compiled like a dream but i am getting really difficult to fix linkage errors ...

 I am using VisualStudio 10 on windows 7 platform. The architecture is Pentium core 2 duo (does that make it 32-bit?) And the Windows 7 OS i am using is listed as a 64-bit operating system... in the My-Computer->Properties section.

Can anyone please guide me through this error correction...i am relatively new to Boost, very new to Boost.Filesystem in particular. I have attached relevant code fragments inline, from the header and source files of the plugin.

EmulatorLaunchPluginAPI.h:

#include <boost/filesystem.hpp>
#include <boost/filesystem/path.hpp>
#include <boost/filesystem/operations.hpp>

const std::string prepare_wave_cmd();
bool locateFile(const bf::path& start_dir_path,
           const std::string& file_name,
   bf::path& path_found);

EmulatorLaunchPluginAPI.cpp:

bool EmulatorLaunchPluginAPI::locateFile(const bf::path& start_dir_path,
           const std::string& file_name,
   bf::path& path_found)
{
if(!bf::exists(start_dir_path))
return false;

bf::directory_iterator end_iter;
for(bf::directory_iterator iter(start_dir_path); iter != end_iter; ++iter)
{
if( is_directory(iter->status()))
{
if(locateFile(iter->path(), file_name, path_found))
return true;
}
else if((iter->path()).leaf() == file_name)
{
path_found = iter->path();
return true;
}
}
return false;
}

const std::string EmulatorLaunchPluginAPI::prepare_wave_cmd()
{
bool found = false;
std::string dir_path;
bf::path output_path;
const bf::path c_path("C:");
const bf::path d_path("D:");
const bf::path e_path("E:");
const bf::path f_path("F:");
const bf::path g_path("G:");
const bf::path h_path("H:");

const std::string exe_file("gtkwave.exe");

if(locateFile(c_path, exe_file, output_path))
{
found = true;
}
else if(locateFile(d_path, exe_file, output_path))
{
found = true;
}
else if(locateFile(e_path, exe_file, output_path))
{
found = true;
}
else if(locateFile(f_path, exe_file, output_path))
{
found = true;
}
else if(locateFile(g_path, exe_file, output_path))
{
found = true;
}
else if(locateFile(h_path, exe_file, output_path))
{
found = true;
}
else
{
found = false;
}

if(true == found)
{
std::string only_dir_path = output_path.string();
size_t pos = only_dir_path.find_last_of("/");
  if(pos != std::string::npos)
{
  dir_path.assign(only_dir_path.begin(), only_dir_path.begin() + pos);
}
}
bf::path pref_path(dir_path);
bf::path native_path = pref_path.make_preferred();
std::string wave_command(native_path.string());
//std::string wave_command("D:\\AJAY\\gtkw\\gtkwave\\lib"); 
wave_command += "\\";
wave_command += m_command.c_str();
wave_command += " ";
wave_command += m_path_wave.c_str();
return wave_command;
}

Output:

Creating library D:/firebreath-FireBreath-c335f5b/build/projects/EmulatorLaunchPlugin/Debug/npEmulatorLaunchPlugin.lib and object D:/firebreath-FireBreath-c335f5b/build/projects/EmulatorLaunchPlugin/Debug/npEmulatorLaunchPlugin.exp

9>EmulatorLaunchPluginAPI.obj : error LNK2019: unresolved external symbol "public: class boost::filesystem::path __thiscall boost::filesystem::path::filename(void)const " (?filename@path@filesystem@boost@@QBE?AV123@XZ) referenced in function "public: class boost::filesystem::path __thiscall boost::filesystem::path::leaf(void)const " (?leaf@path@filesystem@boost@@QBE?AV123@XZ)

9>EmulatorLaunchPluginAPI.obj : error LNK2019: unresolved external symbol "public: int __thiscall boost::filesystem::path::compare(class boost::filesystem::path const &)const " (?compare@path@filesystem@boost@@QBEHABV123@@Z) referenced in function "bool __cdecl boost::filesystem::operator==(class boost::filesystem::path const &,class boost::filesystem::path const &)" (??8filesystem@boost@@YA_NABVpath@01@0@Z)

9>EmulatorLaunchPluginAPI.obj : error LNK2019: unresolved external symbol "class boost::filesystem::file_status __cdecl boost::filesystem::detail::status(class boost::filesystem::path const &,class boost::system::error_code *)" (?status@detail@filesystem@boost@@YA?AVfile_status@23@ABVpath@23@PAVerror_code@system@3@@Z) referenced in function "bool __cdecl boost::filesystem::exists(class boost::filesystem::path const &)" (?exists@filesystem@boost@@YA_NABVpath@12@@Z)

9>EmulatorLaunchPluginAPI.obj : error LNK2019: unresolved external symbol "private: class boost::filesystem::file_status __thiscall boost::filesystem::directory_entry::m_get_status(class boost::system::error_code *)const " (?m_get_status@directory_entry@filesystem@boost@@ABE?AVfile_status@23@PAVerror_code@system@3@@Z) referenced in function "public: class boost::filesystem::file_status __thiscall boost::filesystem::directory_entry::status(void)const " (?status@directory_entry@filesystem@boost@@QBE?AVfile_status@23@XZ)

9>EmulatorLaunchPluginAPI.obj : error LNK2019: unresolved external symbol "void __cdecl boost::filesystem::detail::directory_iterator_construct(class boost::filesystem::directory_iterator &,class boost::filesystem::path const &,class boost::system::error_code *)" (?directory_iterator_construct@detail@filesystem@boost@@YAXAAVdirectory_iterator@23@ABVpath@23@PAVerror_code@system@3@@Z) referenced in function "public: __thiscall boost::filesystem::directory_iterator::directory_iterator(class boost::filesystem::path const &)" (??0directory_iterator@filesystem@boost@@QAE@ABVpath@12@@Z)

9>EmulatorLaunchPluginAPI.obj : error LNK2019: unresolved external symbol "public: class boost::filesystem::path & __thiscall boost::filesystem::path::make_preferred(void)" (?make_preferred@path@filesystem@boost@@QAEAAV123@XZ) referenced in function "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const __thiscall EmulatorLaunchPluginAPI::prepare_wave_cmd(void)" (?prepare_wave_cmd@EmulatorLaunchPluginAPI@@QAE?BV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ)

9>EmulatorLaunchPluginAPI.obj : error LNK2019: unresolved external symbol "public: static class std::codecvt<wchar_t,char,int> const & __cdecl boost::filesystem::path::codecvt(void)" (?codecvt@path@filesystem@boost@@SAABV?$codecvt@_WDH@std@@XZ) referenced in function "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const __thiscall boost::filesystem::path::string(void)const " (?string@path@filesystem@boost@@QBE?BV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ)

9>EmulatorLaunchPluginAPI.obj : error LNK2019: unresolved external symbol "void __cdecl boost::filesystem::path_traits::convert(wchar_t const *,wchar_t const *,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > &,class std::codecvt<wchar_t,char,int> const &)" (?convert@path_traits@filesystem@boost@@YAXPB_W0AAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@ABV?$codecvt@_WDH@5@@Z) referenced in function "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const __thiscall boost::filesystem::path::string(class std::codecvt<wchar_t,char,int> const &)const " (?string@path@filesystem@boost@@QBE?BV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@ABV?$codecvt@_WDH@5@@Z)

9>EmulatorLaunchPluginAPI.obj : error LNK2019: unresolved external symbol "void __cdecl boost::filesystem::detail::directory_iterator_increment(class boost::filesystem::directory_iterator &,class boost::system::error_code *)" (?directory_iterator_increment@detail@filesystem@boost@@YAXAAVdirectory_iterator@23@PAVerror_code@system@3@@Z) referenced in function "private: void __thiscall boost::filesystem::directory_iterator::increment(void)" (?increment@directory_iterator@filesystem@boost@@AAEXXZ)

9>EmulatorLaunchPluginAPI.obj : error LNK2019: unresolved external symbol "void __cdecl boost::filesystem::path_traits::convert(char const *,char const *,class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> > &,class std::codecvt<wchar_t,char,int> const &)" (?convert@path_traits@filesystem@boost@@YAXPBD0AAV?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@ABV?$codecvt@_WDH@5@@Z) referenced in function "void __cdecl boost::filesystem::path_traits::dispatch<class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> > >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> > &,class std::codecvt<wchar_t,char,int> const &)" (??$dispatch@V?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@@path_traits@filesystem@boost@@YAXABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AAV?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@4@ABV?$codecvt@_WDH@4@@Z)

9>EmulatorLaunchPluginAPI.obj : error LNK2019: unresolved external symbol "class boost::system::error_code __cdecl boost::filesystem::detail::dir_itr_close(void * &)" (?dir_itr_close@detail@filesystem@boost@@YA?AVerror_code@system@3@AAPAX@Z) referenced in function "public: __thiscall boost::filesystem::detail::dir_itr_imp::~dir_itr_imp(void)" (??1dir_itr_imp@detail@filesystem@boost@@QAE@XZ)

9>D:\firebreath-FireBreath-c335f5b\build\bin\EmulatorLaunchPlugin\Debug\npEmulatorLaunchPlugin.dll : fatal error LNK1120: 11 unresolved externals

Neil Griffiths

unread,
Sep 2, 2013, 10:20:50 AM9/2/13
to firebre...@googlegroups.com, Soumen Basak, dutta....@gmail.com
You're not linking against the boost filesystem. I'm not sure whether FireBreath comes with that or not. I don't know because I use my own version of boost on all of my supported platforms.


--
 
---
You received this message because you are subscribed to the Google Groups "firebreath-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebreath-de...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Richard Bateman

unread,
Sep 2, 2013, 12:16:51 PM9/2/13
to FireBreath Dev Group

to link against the boost filesystem library, insert the following line into your PluginConfig.cmake and rerun the prep script:

add_boost_library(filesystem)

- Richard

Ajay Prabandham

unread,
Sep 2, 2013, 10:42:12 PM9/2/13
to firebre...@googlegroups.com, Soumen Basak, dutta....@gmail.com
Dear Neil & Richard,
                                 I have now been able to rectify the link error... and code is now running (after some modifications). Thanks for your inputs!

Regards,
Ajay
Reply all
Reply to author
Forward
0 new messages