You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Andrew Hughes <ah...@gmail.com> on 2008/08/07 07:03:32 UTC

maven-native

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.

Re: maven-native

Posted by Andrew Hughes <ah...@gmail.com>.
Ok, it looks as tho I switch my compiler and linker  to g++

           <compilerExecutable>g++</compilerExecutable>
           <linkerExecutable>g++</linkerExecutable>

Thanks Dan.

---------------------------------------------

*working 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>g++</compilerExecutable>
           <linkerExecutable>g++</linkerExecutable>*
         </configuration>
       </plugin>
     </plugins>
   </build>
</project>




On Thu, Aug 7, 2008 at 2:48 PM, Dan Tran <da...@gmail.com> wrote:

> seems like you are using cygwin gcc to compile on a window shell  and
> its does not know how to find the built in STL library.  have u  tried
> with pure cygwin shell ?  i my self have not tried with cygwin ever
> yet.
>
> your project need to build native code with cygwin gcc?
>
> -D
>
> On Wed, Aug 6, 2008 at 10:03 PM, Andrew Hughes <ah...@gmail.com> wrote:
> > 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.
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

Re: maven-native

Posted by Dan Tran <da...@gmail.com>.
seems like you are using cygwin gcc to compile on a window shell  and
its does not know how to find the built in STL library.  have u  tried
with pure cygwin shell ?  i my self have not tried with cygwin ever
yet.

your project need to build native code with cygwin gcc?

-D

On Wed, Aug 6, 2008 at 10:03 PM, Andrew Hughes <ah...@gmail.com> wrote:
> 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.
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org