Jump to content


Math Library Errors while building using Cygwin/GCC (Very Tough)


18 replies to this topic

#1 RyoxSinfar

    New Member

  • Members
  • PipPip
  • 24 posts

Posted 09 June 2006 - 03:54 PM

This will be the 4th day spent trying to get this library to work.

Its an SML library used for advanced math.

I have Cygwin installed so that we can use a GNU compiler. Eventually We will be using C++/OpenGL/SML to do some work and the library is a necessity. I have spoken two 3 people, two who were experienced in with this sort of thing and one tech rep from SML but none have even dented the problem yet.

The situation is this. I have a folder that holds all the files for the library. I have 4 folders and a makefile within the first folder. The makefile is tiny and just calls other makefiles. Two of the folders I am not aware if they do anything. The important two folders are NLib and NMTLib. So far when I told the main makefile to do everything it declared it was working on NLib and running a makefile within that folder (within are a few folders and files for building the library. the fodlers are full of .o .h and .c) this make works without complications and the main makefile continues to change directories and move to NMTLib and begins to work. after about 10 or so minutes it fails declaring Error 2. There is output generated to a txt file that says what happened:

Making libnmtlib.so
g++ -shared -m32 -g -o libnmtlib.so objects/IwAObject.o ... objects/my_nurbs_srf.o -L.:NLib -lnlib (I cut out the other .o's as there are MANY) (Also the addition of :NLib to -L. was added while trying to fix the issue, it came as -L)
/usr/lib/gcc/i686-pc-cygwin/3.4.4/../../../../i686-pc-cygwin/bin/ld: cannot find -lnlib
collect2: ld returned 1 exit status
make[1]: *** [libnmtlib.so] Error 1
make[1]: Leaving directory `/cygdrive/c/Documents and Settings/Julio Gonzales/Desktop/SML resources/SMLib/NMTLib

This error occurs no matter what we have tried. The only thing altering the problem is if we remove -lnlib all together in which I get hundreds of undefined errors instead.

Anyone up to attempting to help with this daunting task please please PLEASE help. you can respond here or contact me at RySinfar on AIM, ryox_sinfar@msn.com on MSN, or RSinfar for yahoo. (AIM or MSN prefered). ICQ is now also an option 233704007

I will be sitting here for hours at work trying to solve the problem so feel free to contact me.

#2 Reedbeta

    DevMaster Staff

  • Administrators
  • 4780 posts
  • LocationBellevue, WA

Posted 09 June 2006 - 04:02 PM

Try moving the -L and -l options to before the list of objects. The error message "cannot find -lnlib" indicates that it is trying to search for a file called -lnlib, i.e. it is not recognizing the library command line option. Some versions of gcc are picky about having all their options in place before the list of files begins.
reedbeta.com - developer blog, OpenGL demos, and other projects

#3 RyoxSinfar

    New Member

  • Members
  • PipPip
  • 24 posts

Posted 09 June 2006 - 04:11 PM

SRCDIR = src
OBJDIR = objects
INCDIR = inc
TARGET = libnmtlib.so

# The list of source files, directly from the file system.
SRCS = $(wildcard $(SRCDIR)/*.cpp)

# The list of object and dependecy files, derived from the source list
# by substituting .o or .d for .cpp
OBJS = $(patsubst $(SRCDIR)/%.cpp,$(OBJDIR)/%.o,$(SRCS))
DEPS = $(patsubst $(SRCDIR)/%.cpp,$(OBJDIR)/%.d,$(SRCS))

# for debug add -g and -D_DEBUG
# for 32bit version use -m32
#removed -DIW_NO_IOS_NOCREATE
CXX = g++
CFLAGS = -I$(INCDIR) -I../NLib/inc -D_DEBUG -DIW_NO_IOS_NOCREATE -DUSE_NEW_IOSTREAMS -DIW_NO_IOS_BINARY -DIW_NOT_BUILDING_MS_DLL -DIW_NOT_USING_OPENGL -DGW_NOT_BUILDING_MS_DLL -g -m32 -o2 -ansi -fPIC -Wall
LIBS = -L.-lnlib

thats the makefile up to where the problem starts, we are currently trying to add to -L to give it an absolute path.

Where should I move it around to?

#4 Reedbeta

    DevMaster Staff

  • Administrators
  • 4780 posts
  • LocationBellevue, WA

Posted 09 June 2006 - 04:12 PM

I mean in the g++ command line. You call g++ with a list of options, followed by the object files, followed by the -L and -l options. Move the latter two before the object files.
reedbeta.com - developer blog, OpenGL demos, and other projects

#5 RyoxSinfar

    New Member

  • Members
  • PipPip
  • 24 posts

Posted 09 June 2006 - 04:29 PM

OH okay, will try that

#6 RyoxSinfar

    New Member

  • Members
  • PipPip
  • 24 posts

Posted 09 June 2006 - 04:37 PM

No its still generating the same error >.<

#7 Reedbeta

    DevMaster Staff

  • Administrators
  • 4780 posts
  • LocationBellevue, WA

Posted 09 June 2006 - 04:39 PM

There is a space between -L. and -lnlib, right? On the section of makefile you posted it looks like there's not.

Also, I assume you've verified that libnlib.a (or libnlib.so) is being generated in the location you think it is?
reedbeta.com - developer blog, OpenGL demos, and other projects

#8 RyoxSinfar

    New Member

  • Members
  • PipPip
  • 24 posts

Posted 09 June 2006 - 04:41 PM

yes I am sure its in two locations, both of which I have tried to access and one is in the same folder as the makefile

Yes there is a space, I accidently removed it in the post only. I had to take out something else I had tried (-L.:NLib and also with the absolute directory)

#9 Reedbeta

    DevMaster Staff

  • Administrators
  • 4780 posts
  • LocationBellevue, WA

Posted 09 June 2006 - 04:55 PM

Just for experiment's sake, what happens if you try replacing -lnlib with some other library you know to be installed correctly (e.g. -lz for zlib)? Does it still fail to find the file? (Obviously it will give undefined symbol errors.) If so, we know there is a problem with library paths in general; if not, try moving your library to the same location (probably /lib) and seeing if it finds it then.

Also, a side note, but I noticed you are using -o libnmtlib.so. You should know that gcc under Cygwin produces standard Windows .dll files, not Linux shared objects (and you wouldn't be able to execute those under Windows even if it did).
reedbeta.com - developer blog, OpenGL demos, and other projects

#10 RyoxSinfar

    New Member

  • Members
  • PipPip
  • 24 posts

Posted 09 June 2006 - 05:03 PM

Would you know of any libraries I could definatly get my hands on? The first programming software was placed on this computer at the begining of this week and I have never used a library and been aware of it or had it called to my attention before >.>

Yes i know what I am doing is beyond me but sadly I have no choice

#11 Reedbeta

    DevMaster Staff

  • Administrators
  • 4780 posts
  • LocationBellevue, WA

Posted 09 June 2006 - 05:15 PM

Cygwin normally installs with some libraries by default. Just check the /lib folder; you can pick virtually anything from in there (except libc). If you apply -l(name) to the linker, it will look for a file called lib(name).a (or lib(name).dll.a), so for instance applying -lz would look for libz.a (that is zlib, a general purpose data compression library).
reedbeta.com - developer blog, OpenGL demos, and other projects

#12 RyoxSinfar

    New Member

  • Members
  • PipPip
  • 24 posts

Posted 09 June 2006 - 05:29 PM

-lz did not generate at an error about there now being an -lz

I put the lnlib.so in the /lib folder and I am trying that

#13 Reedbeta

    DevMaster Staff

  • Administrators
  • 4780 posts
  • LocationBellevue, WA

Posted 09 June 2006 - 05:38 PM

If it still gives you trouble, try renaming it to libnlib.dll. Also, there should be a file generated with a .a extension, for instance libnlib.dll.a, and this will be needed also. (This is the Linux equivalent of an import library; it provides staticly linkable stubs for the dynamically linked functions.)
reedbeta.com - developer blog, OpenGL demos, and other projects

#14 RyoxSinfar

    New Member

  • Members
  • PipPip
  • 24 posts

Posted 09 June 2006 - 05:51 PM

same error yet again T_T

#15 RyoxSinfar

    New Member

  • Members
  • PipPip
  • 24 posts

Posted 09 June 2006 - 05:52 PM

I am going to munch a quick lunch and then try that, though I never saw an .a file anywhere, I will search for one.

(thanks for the help so far!)

#16 RyoxSinfar

    New Member

  • Members
  • PipPip
  • 24 posts

Posted 09 June 2006 - 07:14 PM

A thought just occured to me. Since the make command created libnlib.so itself while in the NLib makefile. Could I have done something wrong to make the libnlib.so file? What if its finding libnlib.so but not finding the flag in there. I dont know if its possible to look in, and if it is VIM couldn't do it...

Workign on trying that other fix now

Edit:
ALSO, when I run the makefile for NMTLib part of the instructions are to back up a folder, enter NLib, then to copy libnlib.so to NMTLib from there. But I am still going to try the .dll

#17 Reedbeta

    DevMaster Staff

  • Administrators
  • 4780 posts
  • LocationBellevue, WA

Posted 09 June 2006 - 08:08 PM

It's a makefile for a real Linux system, so it's only to be expected that there will be some bugs trying to make it under cygwin (for instance, the .so-vs-.dll thing). If you have a real live Linux installation laying around on another computer someplace, you might try building it on that. Of course you would then get out Linux binaries rather than Windows ones.
reedbeta.com - developer blog, OpenGL demos, and other projects

#18 RyoxSinfar

    New Member

  • Members
  • PipPip
  • 24 posts

Posted 09 June 2006 - 08:40 PM

the switch to .dll was unsuccessfull, and I couldn't find a .a file anywhere in either Nlib or NMTLib. Right now I am trying to find the password for the original zip file so I can try starting from scratch.

Sadly no I don't have a unix system laying around >.<

#19 RyoxSinfar

    New Member

  • Members
  • PipPip
  • 24 posts

Posted 14 June 2006 - 03:21 PM

Well we gave up on the problem and decided to just go ahead and use Visual C++ and I double check everything after it goes through the GNU compiler for the other version.

Thanks to all that took any time for the problem.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users