stevemussmann / BayesAss3-SNPs

Modification of BayesAss 3.0.4 to allow handling of large SNP datasets
GNU General Public License v3.0
15 stars 7 forks source link

BayesAss3-SNPs compilation error #2

Closed milaja closed 5 years ago

milaja commented 6 years ago

Hi Steve,

Thank you for putting this program out there!

However, we have a problem trying to compile the program on a university computer cluster (Linux). The cluster manager forwarded me the error, he was using gcc 4.9.3 when compiling. I hope you can help.

The error: g++ -O3 -Wall -c main.cpp main.cpp: In function ‘int main(int, char)’: main.cpp:1153:19: warning: narrowing conversion of ‘l’ from ‘unsigned int’ to ‘char’ inside { } is ill-formed in C++11 [-Wnarrowing] char targ[]={l}, targ2[]={j}; ^ main.cpp:1153:32: warning: narrowing conversion of ‘j’ from ‘unsigned int’ to ‘char’ inside { } is ill-formed in C++11 [-Wnarrowing] char targ[]={l}, targ2[]={j}; ^ main.cpp:1174:29: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] if(iterAllele->second == sampleIndiv[l]->getAllele(j,m)) ^ main.cpp: In function ‘void readInputFile(Indiv, unsigned int&, unsigned int&, unsigned int&, unsigned int*, std::string&, int)’: main.cpp:1257:7: warning: unused variable ‘lastChar’ [-Wunused-variable] char lastChar='a', nextChar; ^ main.cpp:1257:21: warning: variable ‘nextChar’ set but not used [-Wunused-but-set-variable] char lastChar='a', nextChar; ^ main.cpp: In function ‘void getEmpiricalAlleleFreqs(double*, Indiv*, unsigned int, unsigned int, unsigned int, unsigned int, bool)’: main.cpp:1505:42: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] if (sampleIndiv[m]->getAllele(j,0) == k) ^ main.cpp:1508:42: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] if (sampleIndiv[m]->getAllele(j,1) == k) ^ main.cpp: In function ‘void parseComLine(int, char, std::string&, int&, unsigned int&, unsigned int&, unsigned int&, std::string&, double&, double&, double&, bool&, bool&, bool&, bool&, bool&, bool&, int&)’: main.cpp:1735:47: error: ‘class boost::program_options::typed_value<std::basic_string, char>’ has no member named ‘required’ ("file,F", opt::value(&infileName)->required(), "Specify input file") ^ main.cpp:1736:41: error: ‘class boost::program_options::typed_value<int, char>’ has no member named ‘required’ ("loci,l", opt::value(&MAXLOCI)->required(), "Specify number of loci in input file") ^ main.cpp:1768:13: error: ‘required_option’ in namespace ‘opt’ does not name a type catch(opt::required_option& e) //catch errors resulting from required options ^ main.cpp:1770:42: error: ‘e’ was not declared in this scope std::cerr << std::endl << "ERROR: " << e.what() << std::endl << std::endl; ^ make: *** [main.o] Error 1

Many thanks, Milaja

stevemussmann commented 6 years ago

Hello Milaja,

The error that caused compilation to fail seems to be related to the boost program_options library which I used for handling command line input. I have seen a similar error previously when there was a problem with the C++ Boost libraries installation.

What version of the Boost libraries do you have installed? I think the oldest version I have tested is 1.54 and the most recent is 1.60. Also, I once encountered a problem where the program_options library did not install alongside the rest of the Boost installation. I fixed this by either downloading the source for Boost and compiling, or specifically installing the library from my system's package manager. For example, under Ubuntu this would be: sudo apt-get install libboost-program-options-dev

I hope that helps. Let me know if you encounter any more issues,

-Steve

milaja commented 6 years ago

Hi Steve,

And thanks for the extremely fast response!

I have forwarded your reply to our cluster manager, he has had a brief look and he says that the boost libraries version 1.60 is installed as a default. But he didn't have time to test the other options you mentioned and he will have a proper look later. I'll let you know if we continue having problems getting it compiled.

Thanks again and have a nice weekend!

Cheers, Milaja

2018-05-10 11:24 GMT+01:00 Steve Mussmann notifications@github.com:

Hello Milaja,

The error that caused compilation to fail seems to be related to the boost program_options library which I used for handling command line input. I have seen a similar error previously when there was a problem with the C++ Boost libraries installation.

What version of the Boost libraries do you have installed? I think the oldest version I have tested is 1.54 and the most recent is 1.60. Also, I once encountered a problem where the program_options library did not install alongside the rest of the Boost installation. I fixed this by either downloading the source for Boost and compiling, or specifically installing the library from my system's package manager. For example, under Ubuntu this would be: sudo apt-get install libboost-program-options-dev

I hope that helps. Let me know if you encounter any more issues,

-Steve

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/smussmann82/BayesAss3-SNPs/issues/2#issuecomment-388015314, or mute the thread https://github.com/notifications/unsubscribe-auth/AlDmo68usUnnZwx_Vpaqb2X_JsA71p05ks5txBVugaJpZM4T5ng6 .

-- Dr Milaja Nykanen School of Biological, Earth and Environmental Sciences, University College Cork Cork, Ireland

Mobile: +353 (0)85 110 1466

iosefward commented 6 years ago

Hi, I'm currently working on this and I'm stuck. I've pretty much exhausted my limited knowledge of C/Make.

We've got boost (1.60.0) installed in a non-standard location, and the program_options files are there as they'd be normally. $BOOST_ROOT, $BOOST_LIBRARYDIR and $BOOST_INCLUDEDIR are all populated correctly. I've made a test program and it's definitely an issue with it not detecting the boost/program_options but I'm entirely baffled as to why it's not seeing them.

Any ideas of inspiration would be appreciated, otherwise I'll keep plugging away at it.

stevemussmann commented 6 years ago

A couple of ideas:

Maybe try specifying the location of the boost library with -I/path/to/include -L/path/to/library. I spun up a clean Ubuntu virtual machine and tested this by downloading the source for boost 1.60.0 and compiling without installing. I used the following makefile, which you should be able to modify to match your appropriate paths:

all : BA3-SNPS

indiv.o : indiv.h indiv.cpp
        g++ -O3 -Wall -c indiv.cpp

main.o : main.cpp indiv.h BA3.h
        g++ -I/home/mussmann/local/lib/boost_1_60_0 -O3 -Wall -c main.cpp -static

BA3-SNPS : main.o indiv.o
        g++ -L/home/mussmann/local/lib/boost_1_60_0/stage/lib -O3 -Wall -o BA3-SNPS indiv.o main.o -lboost_program_options -lgsl -lgslcblas -static

clean :
        rm *.o BA3-SNPS

Alternativley, a friend of mine made forked this repository and made a conda install package for this program a few days ago. I think it is working, but not 100% sure because I don't really use conda myself. You can find it at: https://github.com/tkchafin/BayesAss3-SNPs

stevemussmann commented 6 years ago

I also just updated the above Makefile code to do static linking because otherwise the library was not being found at runtime.

iosefward commented 6 years ago

Great, thanks for the help (especially since it's an issue on my end rather than yours).

Really oddly, using the above (with appropriate paths), still throws the error above. Doing exactly the same thing, with exactly the same commands, the make file throws a sensible error.

g++ -static -L/shelf/modulefiles/tools/boost/1.60.0/lib -O3 -Wall -o BA3-SNPS indiv.o main.o -lboost_program_options -lgsl -lgslcblas
/usr/bin/ld: cannot find -lboost_program_options
collect2: error: ld returned 1 exit status
make: *** [BA3-SNPS] Error 1

Not sure what the difference is.

I'll have a deeper dig, I'll try re-re-re-doing boost and see if I can make it work.

stevemussmann commented 6 years ago

Any luck getting it to work yet?

If not, I might be able to make a pre-compiled binary this weekend that you can use if you let me know what operating system you are using. I have access to a cloud-based computer cluster that lets me load up virtual machines with various different Linux operating systems. If it's possible, I probably won't have time to do it until this weekend.

Also, if you haven't tried it yet, it may be worth trying the pre-compiled binary that is already in this repository. I compiled it under Ubuntu but it worked fine for me on a cluster running CentOS 6.9.

iosefward commented 6 years ago

We tried the binary to no luck. We're using Redhad 6.9. I think the solution we're settling with at the moment is installing and running it elsewhere. It's by no means ideal but it's got me utterly foxed at the moment.

Thanks for the help!

Edit: got the version wrong.

stevemussmann commented 6 years ago

I unfortunately do not have access to anything running Redhat. Sorry I couldn't be of more assistance. Please let me know if you're able to get it running on a different system.

chenqing-1996 commented 3 years ago

I unfortunately do not have access to anything running Redhat. Sorry I couldn't be of more assistance. Please let me know if you're able to get it running on a different system.

Hi steve, I have similar compilation error with iosefward. I installed gsl and boost by conda but I happend 'fatal error: gsl/gsl_sf_gamma.h: No such file or directory' when I compilated BA3. I can find my gsl_sf_gamma.h in my condasysterm, but It seems that the system could not find it when compiling. I set makefile like as follow:

all : BA3-SNPS

indiv.o : indiv.h indiv.cpp g++ -O3 -Wall -c indiv.cpp

main.o : main.cpp indiv.h BA3.h g++ -I/home/cg/miniconda3/envs/minicondainstall/include/gsl -O3 -Wall -c main.cpp

BA3-SNPS : main.o indiv.o g++ -L/home/cg/miniconda3/envs/minicondainstall/include/gsl -O3 -Wall -o BA3-SNPS indiv.o main.o -lboost_program_options -lgsl -lgslcblas

clean : rm *.o BA3-SNPS

install : cp BA3-SNPS /home/cg/biosoft/BA3_INSTALL/.

How can I solve this problem?