-
November 9th, 2009, 04:46 AM
#1
libm
Anyone know if libm is available for win32? I tried a few Google searches but all I could find were ports for Linux, Solaris etc and complaints from people who couldn't seem to make it work under Windows. However AFAIK it's only a math library so it would be a bit strange if it only worked with certain OS's.
"A problem well stated is a problem half solved.” - Charles F. Kettering
-
November 9th, 2009, 05:09 AM
#2
Re: libm
I have a program, named test.c, for Unix and for Windows. I compile them and they are working well for me.
With Unix, I use:
Code:
gcc -lm -o test.exe test.c
where -lm refers to libm (the "lib" prefix is removed as usual).
With Windows, I use dev-cpp which is creating the following makefile:
Code:
CPP = g++.exe
OBJ = test.o
BIN = test.exe
LINKOBJ = test.o
LIBS = -L"C:/Dev-Cpp/lib"
INCS = -I"C:/Dev-Cpp/include"
CXXINCS = -I"C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include" -I"C:/Dev-Cpp/include/c++/3.4.2/backward" -I"C:/Dev-Cpp/include/c++/3.4.2/mingw32" -I"C:/Dev-Cpp/include/c++/3.4.2" -I"C:/Dev-Cpp/include"
CXXFLAGS = $(CXXINCS)
$(BIN): $(OBJ)
$(CPP) $(LINKOBJ) -o "test.exe" $(LIBS)
test.o: test.c
$(CPP) -c test.c -o test.o $(CXXFLAGS)
where libm is implictly refered since there is libm.a file in C:/Dev-Cpp/lib
-
November 9th, 2009, 05:18 AM
#3
Re: libm
Okay, a slight misunderstanding. I see you're building with mingw (or is it Dev-Cpp? Not sure what that is). In fact I can also build programs that use libm (with Cygwin, in my case) but I was thinking more about building with VC++.
"A problem well stated is a problem half solved.” - Charles F. Kettering
-
November 9th, 2009, 05:23 AM
#4
Re: libm
Yes, Dev-CPP is a GUI for Windows, calling the mingw compiler, which is named g++.exe.
I am sure my program could also be compiled and linked with VC++, without having to install an additional library, but I don't know the name of the equivalent library of libm for VC++.
-
November 9th, 2009, 05:43 AM
#5
Re: libm
Yes, same problem here. Looking at the header files, libm seems to rely quite heavily on the Boost development library (although that does seem to be available for VC++). I'm not sure if it actually links to boost but it does seem to need the header files.
In fact, if I'm looking at the right source modules, libm seems mostly to be inplemented using templates. So I can see why it might not have worked with earlier versions of VC++ but (presumably) it would work with the more up-to-date versions
"A problem well stated is a problem half solved.” - Charles F. Kettering
-
November 9th, 2009, 10:10 AM
#6
Re: libm
libm just provides "standard" math functions for C. Here, "standard" means ISO C[99], Posix, and others.
The MS CRT provides math routines from "C95" (C89 plus amendment 1 corrections).
Are you using something special from libm that isn't provided by the MS CRT?
gg
-
November 9th, 2009, 10:34 AM
#7
Re: libm
No, actually I'm trying to build libsndfile using VC++2005. In libsndfile's config.h file there are loads of options for features that you might or might not have - such as libFLAC, libm, unistd.h, alsa_soundlib and various other things. I'm trying to build it with as much functionality as I can obtain for VC++.
Having said that, I've had a good look through the source code and I can't see anywhere where libm functions are actually used - so it might be something that's now obsolete, or maybe something that's in there for future expansion.
"A problem well stated is a problem half solved.” - Charles F. Kettering
-
November 9th, 2009, 11:38 AM
#8
Re: libm
When you use a function from <math.h>, some system require "-lm" when linking, and some systems don't. This may be all it's trying to determine, whether or not include "-lm" when linking.
gg
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|