ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I am reading the man-pages for autoconf, autoscan, etc but I can't really understand how I can get my program to be installed by the usual "configure && make && make install"-steps.
Do I have to write configure.ac manually and what should be in it? Are there any good guides on how to create this? I would really like to make my program being able to be compiled and installed with these steps instead of using g++ as I do now. :P Since many of my friends are not programmers and that would make my program behave like any program in the compile/installation-process.
It seems that the first step is to create configure.ac and then run autoscan. After that I can't really figure out how ifnames are used and so on.
Please help, this is really confusing, giving me headache. :P
EDIT:
I found a great link to what seems to be a good tutorial about all this. Here it is
I've never used "autoscan", which I guess may be useful.
But some time ago I've figured out the basic part of the procedure.
(and yes, it gave me a headache as well...)
Here's a recipe for the most basic, but complete, example of a "Hello world" program I can think of:
Create a directory for the "hello"-project, and change to that directory:
Now run these commands from the shell (order is more or less important, and you may want to put this in a script "reconf.sh" or whatever):
Code:
touch NEWS README AUTHORS ChangeLog
aclocal
automake -a
autoconf
You'll now have a working configure script.
Run this to create a source tarball:
Code:
./configure
make distcheck
You now have a file "hello-0.1.tar.gz" ready for distribution. "make distcheck" also tests unpacking, configuring, compiling and installing in a temporary directory, which is cleaned up automatically . If you just want to make the package, use "make dist", which is much faster (but doesn't do any testing)
On my (small) website, there is a little bigger autotools example. It uses a config.h, it includes a custom --with-foo switch for the configure-script to enable linking against a (non-existant) "libfoo.so", and a way to #define the datadirectory in config.h (the directory where xpm's, themes or whatever data the program needs), so the program "knows" where to find its data files.
Thank you a lot. I will read some more. The thing now is to understand WHY you are writing that in configure.ac and Makefile.am. I need to understand what to write in these files and why write it.
I will check out your link later, am currently reading about the "Autoconf language", having troubles even to understand that, it's a little bit harder when english isn't my primary language. :P
I have now a program that uses Qt libraries. When I compile manually I do this:
moc on all three .h-files (moc -o moc_file.cc file.h)
Create all object-file (g++ -c -I/usr/lib/qt/include/ -o file.o file.cc), this include the new moc_-files.
Create the binary by linking them together (g++ -L/usr/lib/qt/lib/ -lqt-mt -o bin <all .o-files>)
Notice that I have to specify Qt's include and library, and at the last linking I also use "-lqt-mt". This and running the headers through moc, how can I tell autoconf to do that?
I want configure to check if Qt is installed and compile these files correctly.
Qt is a bit of a problem, because the MOC-stuff is unusual. I've tried to fix this myself once by making a FIND_QT m4 module, but succeeded only partly. See http://qleuren.sf.net/ for this. But this works only with Qt2, so it can be considered broken.
It's probably better to get the m4 module "bnv_have_qt" from the autconf-archive, and include it in your package. How to do this (including a m4 module), see the link I posted before, as it includes the simple "ac_define_dir.m4" as an example.
I check it out and it was very easy to get working. Now my configure can check if Qt is installed but I still have problems with the Makefile.
I noticed that when configure was done the docs on bnv_have_qt said that these vars was defined:
QT_CXXFLAGS
QT_LIBS
QT_MOC
QT_UIC
QT_DIR
How shall I use these in Makefile.am so make will compile everything the "right" way (moc the .h-files, create objects, link the objects)?
Here are an example of the files I have:
myclass.h
myclass.cc
main.cc
Now I normaly moc the myclass.h, make object-files from the two sources and the moc'ed file and finally link all together to a binary file. I want this to be done by "make".
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.