I was working late on a Friday night, setting up an Ubuntu 12.04 machine. Final step was compiling a couple of C++ programs, that worked fine on Ubuntu 10.04, 11.04 and Centos 5. I got linker complaints regarding boost::program_options. Sounded like it wasn't installed. Strange, as I'd installed "libboost-all-dev".
Poke around... all the files seem to be there. The lib files are in /usr/lib/. Surely g++ is already looking there, but I added "-L/usr/lib/" to be sure. No help. I'd tried all the various ideas I found on StackOverflow, until eventually I found http://stackoverflow.com/a/11250976/841830 where "panickal" suggested the list of libraries has to come last. Yeah sure. But getting desperate by this point I give it a try... and it works!
Specifically, in my Makefile, I had to change this line:
$(TARGET): $(OBJS)
$(CXX) -s $(LDFLAGS) $(OBJS) -o $@
To look like this:
$(TARGET): $(OBJS)
$(CXX) -s $(OBJS) -o $@ $(LDFLAGS)
So somewhere between g++ 4.5.2 and g++ 4.6.3 it has gone from being easy-going and taking parameters in any order, to requiring certain ones to come at the end. A strange evolution. (I understand why the ordering amongst the library files matters, I just don't see why they now have to all go together at the end.)
But luckily I was using a Makefile with some structure, so the fix was trivial, and my Friday night did not become a Saturday morning!
Showing posts with label makefile. Show all posts
Showing posts with label makefile. Show all posts
Saturday, December 15, 2012
Tuesday, June 3, 2008
Stopping make delete intermediate files
I wanted a makefile to compile mxml (Adobe flex, aka Flash 9) files into swf files and play them automatically. In other words I wanted to just type "make test2" and it would compile test2.mxml into test2.swf, then open test2.swf in the flashplayer.
The hardest part was that, with the automatic rules, make insisted on deleting the "intermediate" file. But in this case the intermediate file was the swf itself. There is a ".PRECIOUS" rule that appears designed for this purpose that made no difference. After much trial, error and banging my head against the keyboard until it bled, it seems setting ".SECONDARY" to blank was the solution. Here is the full makefile (saved in a file called Makefile, in the same directory as my mxml files):
This makefile is generically useful for when you want to compile and run something; especially when experimenting with lots of small individual files.
The hardest part was that, with the automatic rules, make insisted on deleting the "intermediate" file. But in this case the intermediate file was the swf itself. There is a ".PRECIOUS" rule that appears designed for this purpose that made no difference. After much trial, error and banging my head against the keyboard until it bled, it seems setting ".SECONDARY" to blank was the solution. Here is the full makefile (saved in a file called Makefile, in the same directory as my mxml files):
MXMLC=/usr/local/src/flex3sdk/bin/mxmlc
.SECONDARY:
% : %.swf
flashplayer $<
%.swf: %.mxml
$(MXMLC) $<
This makefile is generically useful for when you want to compile and run something; especially when experimenting with lots of small individual files.
Subscribe to:
Posts (Atom)