Linking headers and libs with gnu make

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Post Reply
Message
Author
2lss
Posts: 225
Joined: Sun 20 Sep 2009, 23:54

Linking headers and libs with gnu make

#1 Post by 2lss »

I'm in the processes of building tilp2 for puppy and I need to compile a bunch of dependencies: libticonv, libtifiles, libticables, and libticalcs. Rather than build one, create a pet, install the pet, ...etc then go back and combine everything into one big pet, I would rather just build everything, combine everything into one directory and run dir2pet. The problem is I don't know how to link the dependencies without installing each one and using pkg-config. For example, I built libticonv ok because it didn't depend on any other tilibs. I used 'new2dir make install' and it created a directory libticonv-1.1 with all the files. I then started on libtifiles but it depends on libticonv. Since I did not install ticonv I don't know how to show make where the files are. The configure --help shows

Code: Select all

TICONV_CFLAGS:  C compiler flags for TICONV, overriding pkg-config
  TICONV_LIBS: linker flags for TICONV, overriding pkg-config
I tried adding

Code: Select all

TICONV_CFLAGS="/path/to/libticonv-1.1" 

TICONV_LIBS="/path/to/libticonv-1.1"  
to ./configure but it make still did not find the headers

Code: Select all

files8x.c:36:20: error: ticonv.h: No such file or directory
I've been reading man pages and tutorials but I can't seem to figure out what the problem is. Do I need to add the "-l" flag? Could anyone out there please explain to me what I'm doing wrong?

User avatar
jemimah
Posts: 4307
Joined: Wed 26 Aug 2009, 19:56
Location: Tampa, FL
Contact:

#2 Post by jemimah »

I use a throw away save file so I can install the needed things to build. Then when I'm done making the pets, I test them on a clean save. It's a lot less of a headache then trying to get configure to find things in nonstandard locations.

Also when I'm building, I just use regular make install, because sometimes the new2dir script screws up. It's easier to find the problem when you know your program worked before you ran the packaging scripts on it.

2lss
Posts: 225
Joined: Sun 20 Sep 2009, 23:54

#3 Post by 2lss »

Hmmm, that sounds like a good idea, I will give it a try. Sometimes I fail to realize that I can do stuff like that with puppy. Although I am still curious how to do it with the configure script in case I'm in a similar situation on a non puppy machine.

So do you create the pet without the new2dir script? Or do you use make install to test the program, then go back and use new2dir?

User avatar
jemimah
Posts: 4307
Joined: Wed 26 Aug 2009, 19:56
Location: Tampa, FL
Contact:

#4 Post by jemimah »

If you run configure --help, there's usually a set of environment variables you can set to specify the locations of stuff.

I do make install first to test the program, then new2dir to create the pet.

Also you should always check the contents of the new directory before running dir2pet to make sure it it hasn't pulled in files you don't need.

User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#5 Post by technosaurus »

or better yet, since all of those libs are highly unlikely to be used by anything else, they should probably be compiled statically (then you won't have to combine all of the libs)
the common ./configure options are:
--enable-static --disable-shared --without-pic

(granted not all libs have a capable configure script)

(here is what I used as a first run for all libs and the binary -- if it fails I start eliminating flags starting with *sections)
CFLAGS=" -pipe -combine -Os -momit-leaf-frame-pointer -fomit-frame-pointer -ffunction-sections -fdata-sections -fmerge-all-constants -mpreferred-stack-boundary=2 -march=i386 -mtune=i686 " LDFLAGS=" -Wl,-O4,-Os,-relax,--sort-common,--gc-sections,-s " ./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var --build=i486-t2-linux-gnu --enable-static --disable-shared --without-pic
Attachments
otherlibs.png
note that no libti* appear since they are statically linked
also shows what others you may need (all are in 431)
(7.45 KiB) Downloaded 1005 times
tilp2-1.14-i486.pet
no ti to test it with - I may have over-optimized it though
(191.84 KiB) Downloaded 518 times
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].

2lss
Posts: 225
Joined: Sun 20 Sep 2009, 23:54

#6 Post by 2lss »

Thanks technosaurus! I gave it a quick try with my ti8-83+ and it seemed to connect fine but the gui didn't respond when I tried to browse files, dump rom, etc. The terminal output had a bunch of glade glib warnings. I will try your instructions later when I get home and see if I can get it to work.

Just out of curiosity, why do you use -march=i386 -mtune=i686? I used -mtune=generic in the past bc I thought mtune implied march.

User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#7 Post by technosaurus »

That is a common problem with glade and optimization if precautions are not taken within the code. Since the code is not used within the binary (it is called via glade) it gets eliminated by the linker as unused code. There is a flag (or flags) that you can pass to prevent that behaviour, but I can't remember (something allong the lines of -fno-*dce or -fno-*dse ??); however, since it negates a lot of optimization anyways, removing the -Os and the *sections flags should fix it and yield similar results. The alternative would be to patch that portion of code so that it isn't eliminated (probably too much work unless you want to be the new maintainer)

-march=i386 uses only 386 instructions which allows the compiler to find more patterns and generally produces smaller code that will work on more machines

-mtune=i686 will just format it to load better on 686 systems (assumes larger stack,register,cache...) but it will still run on older systems
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].

big_bass
Posts: 1740
Joined: Mon 13 Aug 2007, 12:21

#8 Post by big_bass »

Hey 2lss



I first try if the package can be built
and my work horse is slackware 12.2 for testing stuff like this
so that I don't lose a lot of time if it doesnt build there its lamed


this is a perfect example of why an organized approach to building packages is a must *not something extra*

download everything in
http://repository.slacky.eu/slackware-1 ... /1.12/src/

make a folder for tilibs then copy everything for that folder inside

run the tilibs2.SlackBuild build script
it makes and installs the correct libs

cd in to the folder

Code: Select all

./tilibs2.SlackBuild


then change directories into the top src
run the build script tilp2.SlackBuild

Code: Select all

./tilp2.SlackBuild
install tilp2-1.12-i486-1la.tgz

I have a TI 85 but I dont have a cable to test it

years ago I built a circuit and a cable for an older model TI
and connected using qbasic using some how to dont laugh it worked :lol:

enjoy

linux-gate.so.1 =>
libticalcs2.so.7 => /usr/lib/libticalcs2.so.7
libticables2.so.1 => /usr/lib/libticables2.so.1
libtifiles2.so.5 => /usr/lib/libtifiles2.so.5
libticonv.so.3 => /usr/lib/libticonv.so.3
libglade-2.0.so.0 => /usr/lib/libglade-2.0.so.0
libgtk-x11-2.0.so.0 => /usr/lib/libgtk-x11-2.0.so.0
libxml2.so.2 => /usr/lib/libxml2.so.2
libgdk-x11-2.0.so.0 => /usr/lib/libgdk-x11-2.0.so.0
libatk-1.0.so.0 => /usr/lib/libatk-1.0.so.0
libgdk_pixbuf-2.0.so.0 => /usr/lib/libgdk_pixbuf-2.0.so.0
libpangocairo-1.0.so.0 => /usr/lib/libpangocairo-1.0.so.0
libpango-1.0.so.0 => /usr/lib/libpango-1.0.so.0
libcairo.so.2 => /usr/lib/libcairo.so.2
libgobject-2.0.so.0 => /usr/lib/libgobject-2.0.so.0
libgmodule-2.0.so.0 => /usr/lib/libgmodule-2.0.so.0
libglib-2.0.so.0 => /usr/lib/libglib-2.0.so.0
libkdecore.so.4 => /usr/lib/libkdecore.so.4
libkdeui.so.4 => /usr/lib/libkdeui.so.4
libkio.so.4 => /usr/lib/libkio.so.4
libXext.so.6 => /usr/lib/libXext.so.6
libX11.so.6 => /usr/lib/libX11.so.6
libSM.so.6 => /usr/lib/libSM.so.6
libICE.so.6 => /usr/lib/libICE.so.6
libpng12.so.0 => /usr/lib/libpng12.so.0
libresolv.so.2 => /lib/libresolv.so.2
libutil.so.1 => /lib/libutil.so.1
libqt-mt.so.3 => /usr/lib/qt-3.3.8b/lib/libqt-mt.so.3
libjpeg.so.62 => /usr/lib/libjpeg.so.62
libGL.so.1 => /usr/lib/libGL.so.1
libpng.so.3 => /usr/lib/libpng.so.3
libz.so.1 => /usr/lib/libz.so.1
libpthread.so.0 => /lib/libpthread.so.0
libacl.so.1 => /lib/libacl.so.1
libattr.so.1 => /lib/libattr.so.1
libdl.so.2 => /lib/libdl.so.2
libstdc++.so.6 => /usr/lib/libstdc++.so.6
libm.so.6 => /lib/libm.so.6
libgcc_s.so.1 => /usr/lib/libgcc_s.so.1
libc.so.6 => /lib/libc.so.6
libusb-0.1.so.4 => /usr/lib/libusb-0.1.so.4
libXcomposite.so.1 => /usr/lib/libXcomposite.so.1
libXdamage.so.1 => /usr/lib/libXdamage.so.1
libXfixes.so.3 => /usr/lib/libXfixes.so.3
libfontconfig.so.1 => /usr/lib/libfontconfig.so.1
libXrender.so.1 => /usr/lib/libXrender.so.1
libXinerama.so.1 => /usr/lib/libXinerama.so.1
libXi.so.6 => /usr/lib/libXi.so.6
libXrandr.so.2 => /usr/lib/libXrandr.so.2
libXcursor.so.1 => /usr/lib/libXcursor.so.1
libpangoft2-1.0.so.0 => /usr/lib/libpangoft2-1.0.so.0
libfreetype.so.6 => /usr/lib/libfreetype.so.6
libpixman-1.so.0 => /usr/lib/libpixman-1.so.0
libDCOP.so.4 => /usr/lib/libDCOP.so.4
libart_lgpl_2.so.2 => /usr/lib/libart_lgpl_2.so.2
libidn.so.11 => /usr/lib/libidn.so.11
libkdefx.so.4 => /usr/lib/libkdefx.so.4
libxcb-xlib.so.0 => /usr/lib/libxcb-xlib.so.0
libxcb.so.1 => /usr/lib/libxcb.so.1
libXau.so.6 => /usr/lib/libXau.so.6
libXdmcp.so.6 => /usr/lib/libXdmcp.so.6
libmng.so.1 => /usr/lib/libmng.so.1
libXmu.so.6 => /usr/lib/libXmu.so.6
libXft.so.2 => /usr/lib/libXft.so.2
libkdesu.so.4 => /usr/lib/libkdesu.so.4
libkwalletclient.so.1 => /usr/lib/libkwalletclient.so.1
liblcms.so.1 => /usr/lib/liblcms.so.1
libXt.so.6 => /usr/lib/libXt.so.6
libexpat.so.1 => /usr/lib/libexpat.so.1
libfam.so.0 => /usr/lib/libfam.so.0
libXxf86vm.so.1 => /usr/lib/libXxf86vm.so.1
libdrm.so.2 => /usr/lib/libdrm.so.2
/lib/ld-linux.so.2




I noticed that uses an older version of QT and also some kde libs
which would have to be resolved to get a working package on puppy


the good news is the package can be built
now the tinkering begins :D


Joe

2lss
Posts: 225
Joined: Sun 20 Sep 2009, 23:54

#9 Post by 2lss »

technosaurus: I cut out some of the optimization and ended up with

Code: Select all

CFLAGS=" -pipe -combine -momit-leaf-frame-pointer -fomit-frame-pointer -fmerge-all-constants -mpreferred-stack-boundary=2 -march=i386 -mtune=i686 " LDFLAGS=" -Wl,-relax,--sort-common,-s " ./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var --build=i486-t2-linux-gnu --enable-static --disable-shared --without-pic
Everything seems to be working now, however after building the pet I discovered that libticonv did not build statically.

Code: Select all

# ldd /usr/bin/tilp | grep ti
	libticonv.so.4 => /usr/lib/libticonv.so.4 (0xb774c000)
Any idea why this would be?

big_bass: Thanks for the link, I already have tilp installed so I didn't try it yet. The next time I need to build something I will go there first though (most likely grass GIS). It seems like it would be way easier. I wonder how hard it would be to build a 'Master script' that could download all of the components, run the **.SlackBuild script, new2dir, and then dir2pet?

User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#10 Post by technosaurus »

most common reason for me is a typo, usually --enable-static--disable-shared (missing a space between tags)
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].

2lss
Posts: 225
Joined: Sun 20 Sep 2009, 23:54

#11 Post by 2lss »

Ok, got it working. Had to add -Os to CFLAGS.

I have a working pet, now looking for a place to upload. Anyone have any suggestions?

big_bass
Posts: 1740
Joined: Mon 13 Aug 2007, 12:21

#12 Post by big_bass »

2lss

good to hear you got a working package

I still gave it another shot anyway building without kde and static
just so you know there are several ways to solve the same problem
depending on who you ask

I normally don't build static but for this type of small app with many required libs it ok to do so

I made a desktop
and icon that is displayed in the menu
also its all combined in to one package with docs for each package
I also made a slack-desc so its an official package
there is also an install script that makes the symlinks for you all combined

even though I spent much time trying to build puppy packages from source using scripts if you search back a few years starting with getting src2pkg working on puppy 3.01 there has not been much interest from developers... so I now build all my packages from source
as slackware compatible packages this way
anyone that does use linux could easily adjust the package to work
for their version


its 855k
maybe someone may need it so here it is
there may still be something there for you if you compare the packages
http://puppy2.org/slaxer/tilp2-1-i486-2slxr.tgz

Joe
Attachments
tilp2_main_menu.png
(107.09 KiB) Downloaded 997 times
tilp2_console_out.png
(24.7 KiB) Downloaded 850 times

Post Reply