compilation error in mingw environment

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

compilation error in mingw environment

Andy beet
Hi all,

This is a follow on from a previous email. I have minGW (5.1.6), MSYS
(1.0.11), and GSL (1.13) installed i am trying to compile a c script
using the command:

gcc -lgsl -lgslcblas GA-Groups.c -o Groups -Wall -O3 -DHAVE_INLINE

I am on a windows xp sp3 machine

I get the following compilation error:

c:\MinGW\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\mingw32\bin\ld.exe:
cannot find -lgsl
collect2: ld returned 1 exit status

anyone had this error or know which file is missing or even where it
should be located or when it should have been made?

Thanks in advance

Andy

--
Andy Beet
Marine Policy Center
MS #41
Woods Hole Oceanographic Institution
MA 02543
Tel: 508-289-3376
Fax: 508-457-2184
email: [hidden email]



------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
MinGW-users mailing list
[hidden email]

A: Yes.
> Q: Is it really?
>> A: Because the logical conversation flow is disrupted.
>>> Q: Why does MinGW object to top posting?
(abstracted from Larry Hall signature)

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.

Most annoying abuses are:
1) Top posting
2) Thread hijacking
3) HTML/MIME encoded mail
4) Improper quoting
5) Improper trimming
_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Reply | Threaded
Open this post in threaded view
|

Re: compilation error in mingw environment

Tor Lillqvist
> gcc -lgsl -lgslcblas GA-Groups.c -o Groups -Wall -O3 -DHAVE_INLINE

You have managed to get the command line arguments in almost
completely reverse order from what is the norm.... The order does
matter, especially for the -l options which should be *after* the .o
(or .c) files that contain references to the libraries specified by
the -l options.

The more proper command line would be:

gcc  -Wall -O3 -DHAVE_INLINE  -o Groups.exe GA-Groups.c  -lgsl -lgslcblas

(That the location of the -l options doesn't matter on Linux is just
an unfortunate coincidence that lets people to be sloppy and learn bad
habits and pass these bad habits on to others. If you got the above
from some tutorial, please contact the author and tell them to fix
it.)

> cannot find -lgsl

You should also pass a -L option pointing to where the gsl library
(import library) is located. (Presumably on Linux gsl is installed in
a system default location and no -L optio is needed. But in general
for each software package that contains libraries one should be
prepared that it is installed in some arbitrary location and -L
options are needed. It might for instance be that you on purpose have
different versions of the package in different locations.)

Nothing of this is MinGW- or GSL-specific, but fairly generic stuff.
This is how Unix-style command-line compilers have always behaved.

> anyone had this error or know which file is missing or even where it
> should be located

You should know yourself where you have installed the GSL library.

--tml

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
MinGW-users mailing list
[hidden email]

A: Yes.
> Q: Is it really?
>> A: Because the logical conversation flow is disrupted.
>>> Q: Why does MinGW object to top posting?
(abstracted from Larry Hall signature)

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.

Most annoying abuses are:
1) Top posting
2) Thread hijacking
3) HTML/MIME encoded mail
4) Improper quoting
5) Improper trimming
_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Reply | Threaded
Open this post in threaded view
|

Re: compilation error in mingw environment

Andy beet
Cheers Tor,

Thanks for the advice. Yes, i did get this command from someone else who
posted it on their website. I'll let them know.

Regarding the last point. I do know where i installed the GSL library.

So i am assuming the -lgsl argument is refering to the library file
libgsl.a right?

I guess my question from here is that i have searched my machine for
this file and it is not present.
I am figuring it gets made during the make and make install portion of
building the GSL library. However it appears missing. So what happened
to it?

Maybe this is not a question for this user group.

thanks again

andy

Tor Lillqvist wrote:

>> gcc -lgsl -lgslcblas GA-Groups.c -o Groups -Wall -O3 -DHAVE_INLINE
>>    
>
> You have managed to get the command line arguments in almost
> completely reverse order from what is the norm.... The order does
> matter, especially for the -l options which should be *after* the .o
> (or .c) files that contain references to the libraries specified by
> the -l options.
>
> The more proper command line would be:
>
> gcc  -Wall -O3 -DHAVE_INLINE  -o Groups.exe GA-Groups.c  -lgsl -lgslcblas
>
> (That the location of the -l options doesn't matter on Linux is just
> an unfortunate coincidence that lets people to be sloppy and learn bad
> habits and pass these bad habits on to others. If you got the above
> from some tutorial, please contact the author and tell them to fix
> it.)
>
>  
>> cannot find -lgsl
>>    
>
> You should also pass a -L option pointing to where the gsl library
> (import library) is located. (Presumably on Linux gsl is installed in
> a system default location and no -L optio is needed. But in general
> for each software package that contains libraries one should be
> prepared that it is installed in some arbitrary location and -L
> options are needed. It might for instance be that you on purpose have
> different versions of the package in different locations.)
>
> Nothing of this is MinGW- or GSL-specific, but fairly generic stuff.
> This is how Unix-style command-line compilers have always behaved.
>
>  
>> anyone had this error or know which file is missing or even where it
>> should be located
>>    
>
> You should know yourself where you have installed the GSL library.
>
> --tml
>
> ------------------------------------------------------------------------------
> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
> trial. Simplify your report design, integration and deployment - and focus on
> what you do best, core application coding. Discover what's new with
> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
> _______________________________________________
> MinGW-users mailing list
> [hidden email]
>
> A: Yes.
>  
>> Q: Is it really?
>>    
>>> A: Because the logical conversation flow is disrupted.
>>>      
>>>> Q: Why does MinGW object to top posting?
>>>>        
> (abstracted from Larry Hall signature)
>
> This list observes the Etiquette found at
> http://www.mingw.org/Mailing_Lists.
> We ask that you be polite and do the same.
>
> Most annoying abuses are:
> 1) Top posting
> 2) Thread hijacking
> 3) HTML/MIME encoded mail
> 4) Improper quoting
> 5) Improper trimming
> _______________________________________________
> You may change your MinGW Account Options or unsubscribe at:
> https://lists.sourceforge.net/lists/listinfo/mingw-users
>
>  

--
Andy Beet
Marine Policy Center
MS #41
Woods Hole Oceanographic Institution
MA 02543
Tel: 508-289-3376
Fax: 508-457-2184
email: [hidden email]



------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
MinGW-users mailing list
[hidden email]

A: Yes.
> Q: Is it really?
>> A: Because the logical conversation flow is disrupted.
>>> Q: Why does MinGW object to top posting?
(abstracted from Larry Hall signature)

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.

Most annoying abuses are:
1) Top posting
2) Thread hijacking
3) HTML/MIME encoded mail
4) Improper quoting
5) Improper trimming
_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Reply | Threaded
Open this post in threaded view
|

Re: compilation error in mingw environment

Keith Marshall
[Rearranged for proper dialogue flow; please don't top post]

On Wednesday 04 November 2009 19:22:05 Andy beet wrote:

> Tor Lillqvist wrote:
> >> gcc -lgsl -lgslcblas GA-Groups.c -o Groups -Wall -O3
> >> -DHAVE_INLINE
> >
> > You have managed to get the command line arguments in almost
> > completely reverse order from what is the norm.... The order
> > does matter, especially for the -l options which should be
> > *after* the .o (or .c) files that contain references to the
> > libraries specified by the -l options.
> >
> > The more proper command line would be:
> >
> > gcc  -Wall -O3 -DHAVE_INLINE  -o Groups.exe GA-Groups.c  -lgsl
> > -lgslcblas
> >
> > (That the location of the -l options doesn't matter on Linux is
> > just an unfortunate coincidence that lets people to be sloppy
> > and learn bad habits and pass these bad habits on to others.

I've pointed this out before: the location of the -l options *does*
matter on Linux, just as it does for MinGW; you will be punished by
the Linux linker just as severely as by the MinGW linker, if you
misplace them, as the OP did, before the referring objects.  (It is
only a quirk of the handling of *shared* library references on Linux
that makes it *appear* that the order isn't important; you won't see
the effect of this quirk with static libraries).

> >> cannot find -lgsl
> >>    
> >
> > You should also pass a -L option pointing to where the gsl
> > library (import library) is located.
> >
> > [...]
> >
> > You should know yourself where you have installed the GSL
> > library.
>
> Regarding the last point. I do know where i installed the GSL
> library.
>
> So i am assuming the -lgsl argument is refering to the library
> file libgsl.a right?

Yes, or by default, to the import library libgsl.dll.a

> I guess my question from here is that i have searched my machine
> for this file and it is not present.

How did you build and install it?

> I am figuring it gets made during the make and make install
> portion of building the GSL library. However it appears missing.
> So what happened to it?

On the info you've given, I couldn't say.  I did[*]:

  $ mkdir -p $HOME/src
  $ cd $HOME/src
  $ tar xf $HOME/downloads/gsl-1.13.tar.gz
  $ mkdir gsl-1.13/build
  $ cd gsl-1.13/build
  $ ../configure --prefix=c:/mingw
  $ make
  $ make install

The headers were installed in c:/mingw/include/gsl, and the libraries
in c:/mingw/lib -- the standard MinGW locations, so there should be
no need to add -L options.

> Maybe this is not a question for this user group.

It is; no problem there.

[*] I actually did it twice, the first time cross-compiling on Linux
using a mingw32 GCC-3.4.5 cross compiler, the second natively on
WinXP as a VirtualBox guest on the same host, and also using 3.4.5;
just for info, the cross-compile took about three minutes, the
native build over an hour!

--

Regards,
Keith.

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
MinGW-users mailing list
[hidden email]

A: Yes.
> Q: Is it really?
>> A: Because the logical conversation flow is disrupted.
>>> Q: Why does MinGW object to top posting?
(abstracted from Larry Hall signature)

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.

Most annoying abuses are:
1) Top posting
2) Thread hijacking
3) HTML/MIME encoded mail
4) Improper quoting
5) Improper trimming
_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Reply | Threaded
Open this post in threaded view
|

Re: compilation error in mingw environment

sisyphus1
In reply to this post by Andy beet

----- Original Message -----
From: "Andy beet" <[hidden email]>

> So i am assuming the -lgsl argument is refering to the library file
> libgsl.a right?

Right.

> I guess my question from here is that i have searched my machine for
> this file and it is not present.
> I am figuring it gets made during the make and make install portion of
> building the GSL library. However it appears missing. So what happened
> to it?

When you ran 'make install' the file should have been placed in (what the
msys shell regards as) /usr/local/lib. This will be the msys/1.0/local/lib
or msys/local/lib folder.

Cheers,
Rob


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
MinGW-users mailing list
[hidden email]

A: Yes.
> Q: Is it really?
>> A: Because the logical conversation flow is disrupted.
>>> Q: Why does MinGW object to top posting?
(abstracted from Larry Hall signature)

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.

Most annoying abuses are:
1) Top posting
2) Thread hijacking
3) HTML/MIME encoded mail
4) Improper quoting
5) Improper trimming
_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Reply | Threaded
Open this post in threaded view
|

Re: compilation error in mingw environment

Uwe R.
In reply to this post by Andy beet
Hi!

>
> Thanks for the advice. Yes, i did get this command from someone else who
> posted it on their website. I'll let them know.
>
> Regarding the last point. I do know where i installed the GSL library.
>
> So i am assuming the -lgsl argument is refering to the library file
> libgsl.a right?
>
> I guess my question from here is that i have searched my machine for
> this file and it is not present.

Libgsl.a should be on your machine along with libgslcblas.a etc.
after you ran successfully through make and make install.
In my configuration these files are in C:\Mingw\msys\local\lib
... I would guess in your case it is the same.
After you run make you should find the file log in the gsl subdir
with a lot of remarks and the name of the libs built.
In case you dont find it in \Mingw maybe you search the subdir again for
the libs.
However, make sure that msys is in the directory structure of mingw -
otherwise the libs end up somewehere within msys or so.

In case that doesnt help:
unzip gsl to c:\gsl and dont put it into mingw (as suggested in the
installation).
run msys.bat cd to gsl and run ./configure make make install again

Regards
Uwe



------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
MinGW-users mailing list
[hidden email]

A: Yes.
> Q: Is it really?
>> A: Because the logical conversation flow is disrupted.
>>> Q: Why does MinGW object to top posting?
(abstracted from Larry Hall signature)

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.

Most annoying abuses are:
1) Top posting
2) Thread hijacking
3) HTML/MIME encoded mail
4) Improper quoting
5) Improper trimming
_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Reply | Threaded
Open this post in threaded view
|

Re: compilation error in mingw environment

Rüdiger Ranft
In reply to this post by Andy beet
Andy beet schrieb:

> <div class="moz-text-flowed" style="font-family: -moz-fixed">Hi all,
>
> This is a follow on from a previous email. I have minGW (5.1.6), MSYS
> (1.0.11), and GSL (1.13) installed i am trying to compile a c script
> using the command:
>
> gcc -lgsl -lgslcblas GA-Groups.c -o Groups -Wall -O3 -DHAVE_INLINE
>
> I am on a windows xp sp3 machine
>
> I get the following compilation error:
>
> c:\MinGW\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\mingw32\bin\ld.exe:
> cannot find -lgsl
> collect2: ld returned 1 exit status

Did you compile and install gsl? To compile gsl you need to start msys,
go to the source directory (cd /c/path/to/sources/gsl-1.13 when the path
is c:\path\to\sources\gsl-1.13). There you need to run the configure
script (./configure or
./configure --prefix=/c/path/to/install/the/stuff). After this you need
to run make (or make -j8 if you have a quadcore machine) to compile the
software. After the compile process the software needs to be installed,
with "make install". When you gave no --prefix to the configure script,
the software will be installed into /usr/local, when you gave a --prefix
the software will be installed where you choose it.

After this, you should be able to compile and link your software with
the following two commands:

MYPREFIX=/c/path/to/install/the/stuff
gcc GA-Groups.c -o Groups -Wall -O3 -I$MYPREFIX/include -DHAVE_INLINE
-L$MYPREFIX/lib -lgsl -lgslcblas
, the last two lines is actually one line and MYPREFIX is the path where
the software is installed.

bye
Rudi

--
GPG encrypted mails preferred.
GPG verschlüsselte Mails bevorzugt.
---> http://chaosradio.ccc.de/media/ds/ds085.pdf Seite 20 <----

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
MinGW-users mailing list
[hidden email]

A: Yes.
> Q: Is it really?
>> A: Because the logical conversation flow is disrupted.
>>> Q: Why does MinGW object to top posting?
(abstracted from Larry Hall signature)

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.

Most annoying abuses are:
1) Top posting
2) Thread hijacking
3) HTML/MIME encoded mail
4) Improper quoting
5) Improper trimming
_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Reply | Threaded
Open this post in threaded view
|

Re: compilation error in mingw environment

Andy beet
In reply to this post by Uwe R.

>> Regarding the last point. I do know where i installed the GSL library.
>>
>> So i am assuming the -lgsl argument is refering to the library file
>> libgsl.a right?
>>
>> I guess my question from here is that i have searched my machine for
>> this file and it is not present.
>>    
>
> Libgsl.a should be on your machine along with libgslcblas.a etc.
> after you ran successfully through make and make install.
> In my configuration these files are in C:\Mingw\msys\local\lib
> ... I would guess in your case it is the same.
> After you run make you should find the file log in the gsl subdir
> with a lot of remarks and the name of the libs built.
> In case you dont find it in \Mingw maybe you search the subdir again for
> the libs.
> However, make sure that msys is in the directory structure of mingw -
> otherwise the libs end up somewehere within msys or so.
>
> In case that doesnt help:
> unzip gsl to c:\gsl and dont put it into mingw (as suggested in the
> installation).
> run msys.bat cd to gsl and run ./configure make make install again
>
>  
Cheers Uwe,

So it turned out that the libgsl.a file was not in any of the
directories mentioned by other respondents.
In the end i downloaded and installed gsl-1.12 instead of the latest
release (13). Configured and installed fine. the library now exists. The
code now compiles and runs just fine!

Not sure why gsl-1.13 didn't work on my machine - but now i don't care!

Thanks to all who helped. As a newbie i found this mailing list very
helpful and informative.


Andy


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users