dipetkov / eems

Estimating Effective Migration Surfaces
GNU General Public License v2.0
102 stars 28 forks source link

Problem compiling runeems_sats #9

Closed cresnik closed 8 years ago

cresnik commented 8 years ago

Hi

On a Red Hat 6 server with boost 1.59 and eigen3.2.5.2 installed, I'm trying to compile runeems_sats, checkout a328992. I get the following error:

$ make linux g++ -I/usr/local/boost_1.59/include -I/usr/include/eigen3 -O3 -DNDEBUG -c runeems_sats.cpp -o runeems_sats.o g++ -I/usr/local/boost_1.59/include -I/usr/include/eigen3 -O3 -DNDEBUG -c eems.cpp -o eems.o eems.cpp: In member function ‘void EEMS::initialize_diffs()’: eems.cpp:64: error: ‘to_string’ was not declared in this scope make: *\ [eems.o] Error 1

Compiling runeems_snps worked without problem using the same compiler, paths to boost, eigen3 etc.

$ g++ --version g++ (GCC) 4.4.7 20120313 (Red Hat 4.4.7-16)

Any idea what the problem might be? I can provide more info if required.

Thank you and best regards Chris

dipetkov commented 8 years ago

The to_string function converts an integer to a string. It seems that it is not declared in the version of g++ you are using. The simplest solution is to use another method to convert an int to a string, e.g. to use stringstream.

I have changed this one line: (This is an error message that should be invoked if you are using runeems_sat and you try to load a matrix of microsatellite loci that does not match the dimensions of the genotype matrix specified in the parameter .ini file.)

string error_message = "Check that the genotype matrix is a nIndiv-by-" + to_string(alleles_to_read) + " matrix."

to

stringstream alleles_to_read_str; alleles_to_read_str << alleles_to_read;
string error_message = "Check that the genotype matrix is a nIndiv-by-" + alleles_to_read_str.str() + " matrix.");

Using stringstream should be more general than using to_string.

cresnik commented 8 years ago

Hi

Thank you for the quick reply.

I've replaced the one line with the two lines you rewrote, the code now looks like this:

check_condition(Sites.rows() == n && Sites.cols() == alleles_to_read, // "Check that the genotype matrix is a nIndiv-by-" + to_string(alleles_to_read) + " matrix."); stringstream alleles_to_read_str; alleles_to_read_str << alleles_to_read; string error_message = "Check that the genotype matrix is a nIndiv-by-" + alleles_to_read_str.str() + " matrix."); cout << " Read genotype data from " << params.datapath + ".diffs" << endl;

(see the attached screenshot for the code in vim)

Unfortunately, the code doesn't properly compile. I get the following error message:

$ make linux g++ -I/usr/local/boost_1.59/include -I/usr/include/eigen3 -O3 -DNDEBUG -c runeems_sats.cpp -o runeems_sats.o g++ -I/usr/local/boost_1.59/include -I/usr/include/eigen3 -O3 -DNDEBUG -c eems.cpp -o eems.o eems.cpp: In member function ‘void EEMS::initialize_diffs()’: eems.cpp:65: error: expected primary-expression before ‘alleles_to_read_str’ eems.cpp:65: error: ‘alleles_to_read_str’ was not declared in this scope eems.cpp:66: error: expected ‘,’ or ‘;’ before ‘)’ token make: *\ [eems.o] Error 1

Please let me know if you need further information.

Thank you for your help!

Chris

On 20.07.2016 11:50, Desislava Petkova wrote:

The |to_string| function converts an integer to a string. It seems that it is not declared in the version of |g++| you are using. The simplest solution is to use another method to convert an int to a string, e.g. to use |stringstream|.

I have changed this one line: (This is an error message that should be invoked if you are using |runeems_sat| and you try to load a matrix of microsatellite loci that does not match the dimensions of the genotype matrix specified in the parameter |.ini| file.)

|string error_message = "Check that the genotype matrix is a nIndiv-by-"

  • to_string(alleles_to_read) + " matrix." |

to

|stringstream alleles_to_read_str; alleles_to_read_str << alleles_to_read; string error_message = "Check that the genotype matrix is a nIndiv-by-" + alleles_to_read_str.str() + " matrix."); |

Using |stringstream| should be more general than using |to_string|.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/dipetkov/eems/issues/9#issuecomment-233904147, or mute the thread https://github.com/notifications/unsubscribe-auth/AH52c0tNM2VagdpW_MzKd64pmkq8GSxXks5qXe94gaJpZM4JQdzz.

cresnik commented 8 years ago

Ups... looks like I made mistake while doing copy and paste... After deleting the checkout and cloning it again, I was able to compile the binary succesfully.

Please consider the issue solved. Thank you very much for helping so quickly!

Best regards Chris

dipetkov commented 8 years ago

Hi Chris,

Thanks for pointing out this issue and please let me know if you have more questions/comments.

Desi

On Wed, Jul 20, 2016 at 2:44 PM, cresnik notifications@github.com wrote:

Ups... looks like I made mistake while doing copy and paste... After deleting the checkout and cloning it again, I was able to compile the binary succesfully.

Please consider the issue solved. Thank you very much for helping so quickly!

Best regards Chris

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/dipetkov/eems/issues/9#issuecomment-233937853, or mute the thread https://github.com/notifications/unsubscribe-auth/AG0wiYixOVKFNnP4N9U77K-4Y8FryGtIks5qXhgXgaJpZM4JQdzz .