Program won't compile anymore?

Your "-lfoo" parameters should come last on your "g++" command line. So, for example, make this change in your makefile.

Up vote 1 down vote favorite share g+ share fb share tw.

I'm current working on a C++ that I edit locally on my Mac but run on an Ubuntu server. I always make sure that the code compiles on my mac before uploading it to the server to compile it there, where I have to use a makefile to link with libraries that are installed in my local directory. Basically, I had edited a significant portion of my code, found that it compiled on my mac, and uploaded it to the server to compile, but it doesn't compile!

Luckily, I had a backup version of the code, so I tried that on the server, and that won't compile anymore either! In between the last time I knew that my code compiled on the server and now, I know that they ran some updates, but that's all I can think of that's different. For reference, here's my make file: LOCAL_INCLUDE = /home/schraiber/.

Local/include LOCAL_LIB = /home/schraiber/. Local/lib CXXFLAGS = -I$(LOCAL_INCLUDE) CXX_LDFLAGS = -L$(LOCAL_LIB) -lgsl -lm -lgslcblas -lpthread CoalHMMgf: main. O IOUtilities.

O parameters. O Algorithms. O Optimization.

O probabilities. O RNGUtilities. O Data.

O ThreadData. H g++ $(CXXFLAGS) $(CXX_LDFLAGS) main. O IOUtilities.

O parameters. O Algorithms. O Optimization.

O probabilities. O RNGUtilities. O Data.

O -o CoalHMMgf main. O: main. Cpp IOUtilities.

H parameters. H Algorithms. H Optimization.

H probabilities. H ThreadData. H Data.

H g++ $(CXXFLAGS) $(CXX_LDFLAGS) -c main. Cpp IOutilities. O: IOUtilities.

H IOUtilities. Cpp parameters. H data.

H g++ $(CXXFLAGS) $(CXX_LDFLAGS) -c IOUtilities. Cpp parameters. O: parameters.

H parameters. Cpp g++ $(CXXFLAGS) $(CXX_LDFLAGS) -c parameters. Cpp Algorithms.

O: Algorithms. H Algorithms. Cpp g++ $(CXXFLAGS) $(CXX_LDFLAGS) -c Algorithms.

Cpp Optimization. O: Optimization. H Optimization.

Cpp Algorithms. H parameters. H probabilities.

H RNGUtilities. H ThreadData. H IOUtilities.

H g++ $(CXXFLAGS) $(CXX_LDFLAGS) -c Optimization. Cpp probabilities. O: probabilities.

H probabilities. Cpp parameters. H g++ $(CXXFLAGS) $(CXX_LDFLAGS) -c probabilities.

Cpp RNGUtilities. O: RNGUtilities. H RNGUtilities.

Cpp g++ $(CXXFLAGS) $(CXX_LDFLAGS) -c RNGUtilities. Cpp Data. O: Data.

H Data. Cpp g++ $(CXXFLAGS) $(CXX_LDFLAGS) -c Data. Cpp and the error: g++ -I/home/schraiber/.

Local/include -L/home/schraiber/. Local/lib -lgsl -lm -lgslcblas -lpthread main. O IOUtilities.

O parameters. O Algorithms. O Optimization.

O probabilities. O RNGUtilities. O Data.

O -o CoalHMMgf main. O: In function `main': main. Cpp:(.

Text+0xbf1): undefined reference to `pthread_create' main. Cpp:(. Text+0xd0e): undefined reference to `pthread_join' Optimization.

O: In function `my_df(gsl_vector const*, void*, gsl_vector*)': Optimization. Cpp:(. Text+0x3149): undefined reference to `gsl_vector_alloc' Optimization.

Cpp:(. Text+0x316b): undefined reference to `gsl_vector_get' Optimization. Cpp:(.

Text+0x3180): undefined reference to `gsl_vector_set' Optimization. Cpp:(. Text+0x31bc): undefined reference to `gsl_vector_get' Optimization.

Cpp:(. Text+0x31ec): undefined reference to `gsl_vector_set' Optimization. Cpp:(.

Text+0x323b): undefined reference to `gsl_vector_set' Optimization. Cpp:(. Text+0x327e): undefined reference to `gsl_vector_set' Optimization.

Cpp:(. Text+0x32c9): undefined reference to `gsl_vector_set' Optimization. O: In function `MHthreaded(void*)': Optimization.

Cpp:(. Text+0x3489): undefined reference to `gsl_rng_env_setup' Optimization. Cpp:(.

Text+0x3490): undefined reference to `gsl_rng_default' Optimization. Cpp:(. Text+0x360b): undefined reference to `gsl_rng_uniform' Optimization.

Cpp:(. Text+0x3653): undefined reference to `gsl_ran_gaussian' Optimization. Cpp:(.

Text+0x3686): undefined reference to `gsl_ran_gaussian' Optimization. Cpp:(. Text+0x377f): undefined reference to `gsl_rng_uniform' RNGUtilities.

O: In function `AllocRNG(gsl_rng*&, gsl_rng_type const*, int)': RNGUtilities. Cpp:(. Text+0x9a): undefined reference to `gsl_rng_alloc' RNGUtilities.

Cpp:(. Text+0xba): undefined reference to `gsl_rng_set' RNGUtilities. O: In function `FreeRNG(gsl_rng*&)': RNGUtilities.

Cpp:(. Text+0xe3): undefined reference to `gsl_rng_free' collect2: ld returned 1 exit status make: *** CoalHMMgf Error 1 and just to verify that gsl is installed in the local directory: schraiber@trump:~/test_rsync$ ls ~/. Local/lib libbpp-core.

A libbpp-core.so.2.0.0 libbpp-seq.so.9 libgslcblas. A libgslcblas.so.0 libgsl. So pkgconfig libbpp-core.

So libbpp-seq. A libbpp-seq.so.9.1.0 libgslcblas. La libgslcblas.so.0.0.0 libgsl.so.0 python2.7 libbpp-core.so.2 libbpp-seq.

So libgsl. A libgslcblas. So libgsl.

La libgsl.so.0.16.0 schraiber@trump:~/test_rsync$ ls ~/. Local/include/ Bpp gsl An interesting thing to note is that my program is also supposed to link with Bpp, and it does that just fine as far as I can tell. C++ library compiler linker makefile link|improve this question asked Nov 11 '11 at 21:06Joshua Schraiber82.

– Thomas Matthews Nov 11 '11 at 21:08 I believe it's in libgsl.a. – Joshua Schraiber Nov 11 '11 at 21:10.

Your "-lfoo" parameters should come last on your "g++" command line. So, for example, make this change in your makefile: CoalHMMgf: main. O IOUtilities.

O parameters. O Algorithms. O Optimization.

O probabilities. O RNGUtilities. O Data.

O ThreadData. H g++ $(CXXFLAGS) main. O IOUtilities.

O parameters. O Algorithms. O Optimization.

O probabilities. O RNGUtilities. O Data.

O -o CoalHMMgf $(CXX_LDFLAGS).

Wow, that worked! I wonder then why it compiled before, despite having the wrong syntax? The mysteries of the universe, I guess.

Thanks! – Joshua Schraiber Nov 11 '11 at 21:17.

Libraries have to be defined on the link line such that the library containing no other references is the very last one. Libraries that depend on code from a second library need to be listed first. They must be listed after the .

O files, or else the . O files are assumed to be self-contained and don't need the libraries.

– Joshua Schraiber Nov 11 '11 at 21:12 Updated... the . O files need to be before the -l flags. The pthread error should have caught my eye the first time around, as that was a sure indication that the ordering was wrong because that should never have been an missing reference as it is independent of the other libraries.

– Wes Hardaker Nov 11 '11 at 21:22.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions