#include "Poco/Net/NetworkInterface.h"
#include "Poco/Net/Socket.h"
#include <iostream>
#include <vector>
using Poco::Net::NetworkInterface;
using std::vector;
using std::cout;
using std::endl;
using Poco::Net::Socket;
int main()
{
vector<Poco::Net::NetworkInterface> nil = Poco::Net::NetworkInterface::list();
}
E:/c++/Projects/CB1/CBTestMakefile/CppTest.cpp:16: undefined reference to `Poco::Net::NetworkInterface::list()'
obj\Debug\CppTest.o: In function `_ZN9__gnu_cxx13new_allocatorIN4Poco3Net16NetworkInterfaceEE10deallocateEPS3_j':
C:/Program Files/CodeBlocks/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/ext/new_allocator.h:(.text$_ZSt8_DestroyIN4Poco3Net16NetworkInterfaceEEvPT_[void std::_Destroy<Poco::Net::NetworkInterface>(Poco::Net::NetworkInterface*)]+0xd): undefined reference to `Poco::Net::NetworkInterface::~NetworkInterface()'
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 30 seconds)
2 errors, 0 warnings
obj\Debug\CppTest.o||In function `main':|
E:\c++\Projects\CB1\CBTestMakefile\CppTest.cpp|16|undefined reference to `Poco::Net::NetworkInterface::list()'|
obj\Debug\CppTest.o||In function `_ZN9__gnu_cxx13new_allocatorIN4Poco3Net16NetworkInterfaceEE10deallocateEPS3_j':|
)]+0xd)||undefined reference to `Poco::Net::NetworkInterface::~NetworkInterface()'|
||=== Build finished: 2 errors, 0 warnings ===|
#include <boost/regex.hpp>
#include <iostream>
#include <string>
int main()
{
std::string line;
boost::regex pat( "^Subject: (Re: |Aw: )*(.*)" );
while (std::cin)
{
std::getline(std::cin, line);
boost::smatch matches;
if (boost::regex_match(line, matches, pat))
std::cout << matches[2] << std::endl;
}
}
obj\Debug\CppTest.o||In function `_ZN9__gnu_cxxmiIPKcS2_SsEENS_17__normal_iteratorIT_T1_E15difference_typeERKS6_RKNS3_IT0_S5_EE':|
boost::regex_constants::_match_flags)]+0x9a)||undefined reference to `boost::re_detail::perl_matcher<__gnu_cxx::__normal_iterator<char const*, std::string>, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char const*, std::string> > >, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::match()'|
unsigned int)]+0x22)||undefined reference to `boost::basic_regex<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::do_assign(char const*, char const*, unsigned int)'|
obj\Debug\CppTest.o||In function `main':|
E:\c++\Projects\CB1\CBTestMakefile\CppTest.cpp|6|undefined reference to `boost::re_detail::perl_matcher<__gnu_cxx::__normal_iterator<char const*, std::string>, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char const*, std::string> > >, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::construct_init(boost::basic_regex<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > > const&, boost::regex_constants::_match_flags)'|
||=== Build finished: 3 errors, 0 warnings ===|
project -> Build options
-> linker : Add the libs
-> Search directory -> Linker : Add the libs path
Base : C:\projets\cpp\boost_1_36_0 (for me)
Include : C:\projets\cpp\boost_1_36_0
lib : C:\projets\cpp\boost_1_36_0\bin.v2\libs
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_project_file>
<FileVersion major="1" minor="6" />
<Project>
<Option title="CodeBlocksTest" />
<Option pch_mode="2" />
<Option compiler="gcc" />
<Build>
<Target title="Debug">
<Option output="bin\Debug\CodeBlocksTest" prefix_auto="1" extension_auto="1" />
<Option object_output="obj\Debug\" />
<Option type="1" />
<Option compiler="gcc" />
<Compiler>
<Add option="-g" />
<Add directory="$(#boost.include)" />
</Compiler>
<Linker>
<Add library="..\..\boost_1_36_0\lib\boost_regex-vc90-mt-1_36.lib" />
<Add directory="$(#boost.lib)" />
</Linker>
</Target>
<Target title="Release">
<Option output="bin\Release\CodeBlocksTest" prefix_auto="1" extension_auto="1" />
<Option object_output="obj\Release\" />
<Option type="1" />
<Option compiler="gcc" />
<Compiler>
<Add option="-O2" />
</Compiler>
<Linker>
<Add option="-s" />
</Linker>
</Target>
</Build>
<Compiler>
<Add option="-Wall" />
<Add option="-fexceptions" />
</Compiler>
<Unit filename="main.cpp" />
<Extensions>
<code_completion />
<envvars />
<debugger />
<lib_finder disable_auto="1" />
</Extensions>
</Project>
</CodeBlocks_project_file>
#include <boost/regex.hpp>
#include <iostream>
#include <string>
#include <vector>
#include "Poco/Net/NetworkInterface.h"
using Poco::Net::NetworkInterface;
using std::cout;
using std::vector;
using std::endl;
int main()
{
std::string line;
boost::regex pat( "^Subject: (Re: |Aw: )*(.*)" );
while (std::cin)
{
std::getline(std::cin, line);
boost::smatch matches;
if (boost::regex_match(line, matches, pat))
std::cout << matches[2] << std::endl;
}
vector<NetworkInterface> nil = NetworkInterface::list();
for (NetworkInterface::NetworkInterfaceList::iterator iter = nil.begin();
iter != nil.end(); ++iter)
{
NetworkInterface ni = *iter;
cout << "Network interface: " << ni.name() << endl
<< " Submenet mask:" << ni.subnetMask().toString() << endl
<< " Broadcast: " << ni.broadcastAddress().toString() << endl
<< " Address: " << ni.address().toString() << endl
<< endl;
}
}
-------------- Build: Debug in CodeBlocksTest ---------------
[ 50.0%] mingw32-g++.exe -Wall -fexceptions -DPOCO_STATIC -g -IC:\boost_1_36_0\include\boost-1_36 -IC:\poco\svn\Foundation\include -IC:\poco\svn\Net\include -c C:\Projects\CodeBlocksTest\main.cpp -o obj\Debug\main.o
[100.0%] mingw32-g++.exe -LC:\boost_1_36_0\lib -LC:\poco\svn\lib -o bin\Debug\CodeBlocksTest.exe obj\Debug\main.o C:\boost_1_36_0\lib\boost_regex-vc90-mt-1_36.lib C:\poco\svn\lib\PocoFoundationmtd.lib C:\poco\svn\lib\PocoNetmtd.lib
obj\Debug\main.o: In function `main':
C:/Projects/CodeBlocksTest/main.cpp:27: undefined reference to `Poco::Net::NetworkInterface::list()'
C:/Projects/CodeBlocksTest/main.cpp:31: undefined reference to `Poco::Net::NetworkInterface::NetworkInterface(Poco::Net::NetworkInterface const&)'
C:/Projects/CodeBlocksTest/main.cpp:32: undefined reference to `Poco::Net::NetworkInterface::address() const'
C:/Projects/CodeBlocksTest/main.cpp:32: undefined reference to `Poco::Net::IPAddress::toString() const'
C:/Projects/CodeBlocksTest/main.cpp:32: undefined reference to `Poco::Net::NetworkInterface::broadcastAddress() const'
C:/Projects/CodeBlocksTest/main.cpp:32: undefined reference to `Poco::Net::IPAddress::toString() const'
C:/Projects/CodeBlocksTest/main.cpp:32: undefined reference to `Poco::Net::NetworkInterface::subnetMask() const'
C:/Projects/CodeBlocksTest/main.cpp:32: undefined reference to `Poco::Net::IPAddress::toString() const'
C:/Projects/CodeBlocksTest/main.cpp:32: undefined reference to `Poco::Net::NetworkInterface::name() const'
C:/Projects/CodeBlocksTest/main.cpp:32: undefined reference to `Poco::Net::NetworkInterface::~NetworkInterface()'
C:/Projects/CodeBlocksTest/main.cpp:32: undefined reference to `Poco::Net::NetworkInterface::~NetworkInterface()'
obj\Debug\main.o: In function `ZN9__gnu_cxxmiIPKcS2_SsEENS_17__normal_iteratorIT_T1_E15difference_typeERKS6_RKNS3_IT0_S5_EE':
C:/boost_1_36_0/include/boost-1_36/boost/regex/v4/basic_regex.hpp:(.text$_ZN5boost11regex_matchIN9__gnu_cxx17__normal_iteratorIPKcSsEESaINS_9sub_matchIS5_EEEcNS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEEEbT_SD_RNS_13match_resultsISD_T0_EERKNS_11basic_regexIT1_T2_EENS_15regex_constants12_match_flagsE[bool boost::regex_match<__gnu_cxx::__normal_iterator<char const*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char const*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > > > >, char, boost::regex_traits<char, boost::cpp_regex_traits<char> > >(__gnu_cxx::__normal_iterator<char const*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, __gnu_cxx::__normal_iterator<char const*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, boost::match_results<__gnu_cxx::__normal_iterator<char const*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char const*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > > > > >&, boost::basic_regex<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > > const&, boost::regex_constants::_match_flags)]+0x9a): undefined reference to `boost::re_detail::perl_matcher<__gnu_cxx::__normal_iterator<char const*, std::string>, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char const*, std::string> > >, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::match()'
C:/boost_1_36_0/include/boost-1_36/boost/regex/v4/basic_regex.hpp:(.text$_ZN5boost11basic_regexIcNS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEE6assignEPKcS7_j[boost::basic_regex<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::assign(char const*, char const*, unsigned int)]+0x22): undefined reference to `boost::basic_regex<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::do_assign(char const*, char const*, unsigned int)'
obj\Debug\main.o: In function `main':
C:/Projects/CodeBlocksTest/main.cpp:13: undefined reference to `boost::re_detail::perl_matcher<__gnu_cxx::__normal_iterator<char const*, std::string>, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char const*, std::string> > >, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::construct_init(boost::basic_regex<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > > const&, boost::regex_constants::_match_flags)'
obj\Debug\main.o: In function `ZN9__gnu_cxxmiIPKcS2_SsEENS_17__normal_iteratorIT_T1_E15difference_typeERKS6_RKNS3_IT0_S5_EE':
C:/boost_1_36_0/include/boost-1_36/boost/regex/v4/basic_regex.hpp:(.text$_ZSt8_DestroyIN4Poco3Net16NetworkInterfaceEEvPT_[void std::_Destroy<Poco::Net::NetworkInterface>(Poco::Net::NetworkInterface*)]+0xd): undefined reference to `Poco::Net::NetworkInterface::~NetworkInterface()'
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 3 seconds)
15 errors, 0 warnings
This is wrong. You're using MinGW; you need to link with the MinGW version of a library, not the Visual C++ version.Code[100.0%] mingw32-g++.exe <...> C:\boost_1_36_0\lib\boost_regex-vc90-mt-1_36.lib <...>
This is wrong. You're using MinGW; you need to link with the MinGW version of a library, not the Visual C++ version.Just for the record: If you compile boost in this version with MinGW/GCC it will create *.lib files (*not* *.a files). So (s)he might in fact be using the MinGW/GCC variant correctly. This already lead to confusion in another thread in our forum. Maybe a search will help...?!
Just for the record: If you compile boost in this version with MinGW/GCC it will create *.lib files (*not* *.a files). So (s)he might in fact be using the MinGW/GCC variant correctly. This already lead to confusion in another thread in our forum. Maybe a search will help...?!
BTW: I just renamed the files to *.a in my copy.
Just for the record: If you compile boost in this version with MinGW/GCC it will create *.lib files (*not* *.a files). So (s)he might in fact be using the MinGW/GCC variant correctly.Look at the file name. boost_regex-vc90-mt-1_36.lib is for Visual C++ 9.0. For MinGW, it should be boost_regex-gcc34-mt-1_36.lib. (Depending on the GCC version.)
Look at the file name. boost_regex-vc90-mt-1_36.lib is for Visual C++ 9.0. For MinGW, it should be boost_regex-gcc34-mt-1_36.lib. (Depending on the GCC version.)Ooops - you are correct. My fault. :oops: