Howdy,

Our projects are a mixture of cpp and java and I'd love to use maven just
like I have in the past for purely java project.

Consequently, Im trying to use the maven-native plugin but I am struggling!
So any help would be great!

First up I've installed cygwin and the gcc compiler. My goal is to produce
an .exe. I have created my maven project as follows:

*./pom.xml*

<project>
  <modelVersion>4.0.0</modelVersion>
  <groupId>debug</groupId>
  <artifactId>helloworld-cpp</artifactId>
  <version>1.0-SNAPSHOT</version>
  <name>helloworld-cpp</name>
  <packaging>exe</packaging>
   <build>
     <plugins>
       <plugin>
         <groupId>org.codehaus.mojo</groupId>
         <artifactId>native-maven-plugin</artifactId>
         <extensions>true</extensions>
         <configuration>
           <sources>
             <source>
               <directory>./src/main/cpp</directory>
               <includes>
                 <include>*.cpp</include>
               </includes>
             </source>
           </sources>
           <compilerProvider>generic-classic</compilerProvider>
           <compilerExecutable>gcc</compilerExecutable>
         </configuration>
       </plugin>
     </plugins>
   </build>
</project>

*./src/main/cpp/HelloWorld.cpp*

#include <iostream>
using namespace std;
int main()
{
  cout << "Hello world" << endl;
}


Thats it!

When I try and build the project I get the following error... which
unfortunately means nothing to me.
$ mvn install
[INFO] Scanning for projects...
[INFO]
------------------------------------------------------------------------
[INFO] Building helloworld-cpp
[INFO]    task-segment: [install]
[INFO]
------------------------------------------------------------------------
[INFO] [native:initialize]
[INFO] [native:compile]
[INFO] [native:link]
[INFO] gcc -oc:\Temp\helloworldcpp\target\helloworld-cpp.exe
target\HelloWorld.obj
target\HelloWorld.obj:HelloWorld.cpp:(.text+0xd): undefined reference to
`std::basic_string<char, std::char_traits<char>, std::allocator<char>
>::size() const'
target\HelloWorld.obj:HelloWorld.cpp:(.text+0x60): undefined reference to
`std::basic_string<char, std::char_traits<char>, std::allocator<char>
>::operator[](unsigned int) const'
target\HelloWorld.obj:HelloWorld.cpp:(.text+0x9f): undefined reference to
`std::basic_string<char, std::char_traits<char>, std::allocator<char>
>::operator[](unsigned int)  const'
target\HelloWorld.obj:HelloWorld.cpp:(.text+0xce): undefined reference to
`std::basic_string<char, std::char_traits<char>, std::allocator<char>
>::operator[](unsigned int)  const'
target\HelloWorld.obj:HelloWorld.cpp:(.text+0x135): undefined reference to
`std::cout'
target\HelloWorld.obj:HelloWorld.cpp:(.text+0x13a): undefined reference to
`std::basic_ostream<char, std::char_traits<char> >& std::operator<<
<std::char_traits<char>  >(std::basic_ostream<char, std::c
har_traits<char> >&, char const*)'
target\HelloWorld.obj:HelloWorld.cpp:(.text+0x142): undefined reference to
`std::basic_ostream<char, std::char_traits<char> >& std::endl<char,
std::char_traits<char> >(std::basic_ostream<char, std::ch
ar_traits<char> >&)'
target\HelloWorld.obj:HelloWorld.cpp:(.text+0x14a): undefined reference to
`std::basic_ostream<char, std::char_traits<char>
>::operator<<(std::basic_ostream<char, std::char_traits<char> >& (*)(std::ba
sic_ostream<char, std::char_traits<char> >&))'
target\HelloWorld.obj:HelloWorld.cpp:(.text+0x173): undefined reference to
`std::ios_base::Init::Init()'
target\HelloWorld.obj:HelloWorld.cpp:(.text+0x18e): undefined reference to
`std::ios_base::Init::~Init()'
collect2: ld returned 1 exit status
[INFO]
------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO]
------------------------------------------------------------------------
[INFO] Error executing command line. Exit code:1

[INFO]
------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO]
------------------------------------------------------------------------
[INFO] Total time: 1 second
[INFO] Finished at: Thu Aug 07 14:28:46 CST 2008
[INFO] Final Memory: 4M/9M
[INFO]
------------------------------------------------------------------------



Any help would be much appreciated. Thankyou.

Reply via email to