Roy-lab / scMTNI

21 stars 4 forks source link

Cannot link GSL correctly #15

Closed mapo121 closed 6 months ago

mapo121 commented 6 months ago

Hello,

I cannot find the compiler that is described in the documentation GCC version of gcc-6.3.1 and GNU extension with std=gnu++14

Any link or old attachment is appreciated.

Thank you

sgmccalla commented 6 months ago

Could you please list your 1) operating system 2) your current compiler 3) the command and error are you getting.

mapo121 commented 6 months ago

1) NAME="AlmaLinux" VERSION="8.9 (Midnight Oncilla)" ID="almalinux" ID_LIKE="rhel centos fedora" VERSION_ID="8.9" PLATFORM_ID="platform:el8" PRETTY_NAME="AlmaLinux 8.9 (Midnight Oncilla)" ANSI_COLOR="0;34" LOGO="fedora-logo-icon" CPE_NAME="cpe:/o:almalinux:almalinux:8::baseos" HOME_URL="https://almalinux.org/" DOCUMENTATION_URL="https://wiki.almalinux.org/" BUG_REPORT_URL="https://bugs.almalinux.org/"

ALMALINUX_MANTISBT_PROJECT="AlmaLinux-8"
ALMALINUX_MANTISBT_PROJECT_VERSION="8.9"
REDHAT_SUPPORT_PRODUCT="AlmaLinux"
REDHAT_SUPPORT_PRODUCT_VERSION="8.9"

2)

This is my make version
 GNU Make 4.2.1
 Built for x86_64-redhat-linux-gnu
 Copyright (C) 1988-2016 Free Software Foundation, Inc.
 License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
 This is free software: you are free to change and redistribute it.
  There is NO WARRANTY, to the extent permitted by law.

This is my gcc version

Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/util/comp/gcc/11.2.0/libexec/gcc/x86_64-pc-linux-gnu/11.2.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-11.2.0/configure --prefix=/util/comp/gcc/11.2.0 --disable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 11.2.0 (GCC) 

3) I'm running make inside the scMTNI/Code/ as instructed

neMap.C -I common/ -I orthomapsparser/ -lgsl -lgslcblas -g -std=gnu++14 -gdwarf-2 -o scMTNI In file included from common/EvidenceManager.H:8, from Framework.C:26: common/Matrix.H:6:10: fatal error: gsl/gsl_matrix.h: No such file or directory 6 | #include <gsl/gsl_matrix.h> | ^~~~~~ compilation terminated. In file included from common/EvidenceManager.H:8, from MetaLearner.C:27: common/Matrix.H:6:10: fatal error: gsl/gsl_matrix.h: No such file or directory 6 | #include <gsl/gsl_matrix.h> | ^~~~~~ compilation terminated. In file included from SpeciesDataManager.C:19: common/Potential.H:10:10: fatal error: gsl/gsl_randist.h: No such file or directory 10 | #include "gsl/gsl_randist.h" | ^~~~~~~ compilation terminated. SpeciesDistance.C: In member function ‘int SpeciesDistance::setspeciesNameIDMap(std::unordered_map<std::__cxx11::basic_string, int>&)’: SpeciesDistance.C:49:1: warning: no return statement in function returning non-void [-Wreturn-type] 49 | } | ^ In file included from common/EvidenceManager.H:8, from common/EvidenceManager.C:27: common/Matrix.H:6:10: fatal error: gsl/gsl_matrix.h: No such file or directory 6 | #include <gsl/gsl_matrix.h> | ^~~~~~ compilation terminated. In file included from common/Potential.C:20: common/Potential.H:10:10: fatal error: gsl/gsl_randist.h: No such file or directory 10 | #include "gsl/gsl_randist.h" | ^~~~~~~ compilation terminated. In file included from common/SlimFactor.C:17: common/Potential.H:10:10: fatal error: gsl/gsl_randist.h: No such file or directory 10 | #include "gsl/gsl_randist.h" | ^~~~~~~ compilation terminated. common/Graph.C: In member function ‘int Graph::showDegreeDist(const char*)’: common/Graph.C:277:1: warning: no return statement in function returning non-void [-Wreturn-type] 277 | } | ^ In file included from common/Matrix.C:15: common/Matrix.H:6:10: fatal error: gsl/gsl_matrix.h: No such file or directory 6 | #include <gsl/gsl_matrix.h> | ^~~~~~ compilation terminated. common/PotentialManager.C:18:10: fatal error: gsl/gsl_blas.h: No such file or directory 18 | #include <gsl/gsl_blas.h> | ^~~~ compilation terminated. make: *** [Makefile:10: condSpecLearner] Error 1

sgmccalla commented 6 months ago

Based on the errors, I suspect that GNU Scientific Library (gsl) might not be installed. Please check if gsl is installed, and if not you could follow installation instructions from here (caveat that I have not tested these instructions and you might have to adapt them): https://coral.ise.lehigh.edu/jild13/2016/07/11/hello/ or try: sudo apt install libgsl-dev

mapo121 commented 6 months ago

I'm in the MakeFile now, I have gsl installed. Where do you link the GSL library inside of your makefile?

LFLAG = -lgsl -lgslcblas
SRC = Framework.C  MetaLearner.C  MetaMove.C    SpeciesDataManager.C    SpeciesDistance.C        common/Error.C    common/EvidenceManager.C  common/Potential.C    common/SlimFactor.C  common/VariableManager.C common/Evidence.C  common/FactorGraph.C      common/Graph.C         common/Matrix.C            common/PotentialManager.C       common/Utils.C  common/Variable.C       common/Vertex.C  orthomapsparser/MappedOrthogroupReader.C       orthomapsparser/MappedOrthogroup.C orthomapsparser/GeneMap.C
INCLPATH2 = common/
INCLPATH3 = orthomapsparser/

CC=g++
CFLAGS = -g -std=gnu++14 -gdwarf-2

condSpecLearner: $(SRC)
        $(CC) $(SRC) -I $(INCLPATH2) -I $(INCLPATH3)  $(LFLAG) $(CFLAGS) -o scMTNI
sroyyors commented 6 months ago

hi Moses, what is the error you are getting when you compile? It seems you have provided a link to the gsl library in your email you sent us. Please do not use both email and GitHub with separate messages. Please only use GitHub.

mapo121 commented 6 months ago

Its the same error that GSL cannot be found. I wanted to know how you would link the GSL library in the makefile you have. I added my GSL path to my PATH variable already.

sroyyors commented 6 months ago

Sorry can you paste the error here? You have to use the -L option before $(LFLAG)and specify the path to the gsl_lib folder and -I flag for the gsl_include folders.

mapo121 commented 6 months ago

Attempt to correct the Makefile

LFLAG = -lgsl -lgslcblas 
SRC = Framework.C  MetaLearner.C  MetaMove.C    SpeciesDataManager.C    SpeciesDistance.C    common/Error.C    common/EvidenceManager.C  common/Potential.   common/SlimFactor.C    common/VariableManager.C common/Evidence.C  common/FactorGraph.C      common/Graph.C         common/Matrix.C        common/PotentialManager.C   common/Utils.C  common/Variable.C   common/Vertex.C  orthomapsparser/MappedOrthogroupReader.C   orthomapsparser/MappedOrthogroup.C orthomapsparser/GeneMap.C
INCLPATH2 = common/
INCLPATH3 = orthomapsparser/
INCLPATH4 = /work/WORK/binaries/gsl/lib/  # my 
CC=g++
CFLAGS = -g -std=gnu++14 -gdwarf-2

condSpecLearner: $(SRC)
    $(CC) -Wall $(SRC) -I $(INCLPATH2) -I $(INCLPATH3)  -L $(INCLPATH4) $(LFLAG) $(CFLAGS) -o scMTNI

And the error message


In file included from common/EvidenceManager.H:8,
                 from Framework.C:26:
common/Matrix.H:6:10: fatal error: gsl/gsl_matrix.h: No such file or directory
    6 | #include <gsl/gsl_matrix.h>
      |          ^~~~~~~~~~~~~~~~~~
compilation terminated.
In file included from common/EvidenceManager.H:8,
                 from MetaLearner.C:27:
common/Matrix.H:6:10: fatal error: gsl/gsl_matrix.h: No such file or directory
    6 | #include <gsl/gsl_matrix.h>
      |          ^~~~~~~~~~~~~~~~~~
compilation terminated.
In file included from SpeciesDataManager.C:19:
common/Potential.H:10:10: fatal error: gsl/gsl_randist.h: No such file or directory
   10 | #include "gsl/gsl_randist.h"
      |          ^~~~~~~~~~~~~~~~~~~
compilation terminated.
SpeciesDistance.C: In member function ‘int SpeciesDistance::setspeciesNameIDMap(std::unordered_map<std::__cxx11::basic_string<char>, int>&)’:
SpeciesDistance.C:49:1: warning: no return statement in function returning non-void [-Wreturn-type]
   49 | }
      | ^
SpeciesDistance.C: In member function ‘double SpeciesDistance::getEdgeStatusProb(std::vector<int>&)’:
SpeciesDistance.C:206:26: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::vector<int>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
  206 |     for(int eIter=0;eIter<edgeStatus.size();eIter++)
      |                     ~~~~~^~~~~~~~~~~~~~~~~~
SpeciesDistance.C:239:18: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::vector<SpeciesDistance::Species*>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
  239 |     for(int i=0;i<root->children.size();i++)
      |                 ~^~~~~~~~~~~~~~~~~~~~~~
SpeciesDistance.C: In member function ‘double SpeciesDistance::getSubTree(bool, SpeciesDistance::Species*, std::vector<int>&)’:
SpeciesDistance.C:315:22: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::vector<SpeciesDistance::Species*>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
  315 |         for(int i=0;i<child->children.size();i++)
      |                     ~^~~~~~~~~~~~~~~~~~~~~~~
In file included from common/EvidenceManager.H:8,
                 from common/EvidenceManager.C:27:
common/Matrix.H:6:10: fatal error: gsl/gsl_matrix.h: No such file or directory
    6 | #include <gsl/gsl_matrix.h>
      |          ^~~~~~~~~~~~~~~~~~
compilation terminated.
In file included from common/Potential.C:20:
common/Potential.H:10:10: fatal error: gsl/gsl_randist.h: No such file or directory
   10 | #include "gsl/gsl_randist.h"
      |          ^~~~~~~~~~~~~~~~~~~
compilation terminated.
In file included from common/SlimFactor.C:17:
common/Potential.H:10:10: fatal error: gsl/gsl_randist.h: No such file or directory
   10 | #include "gsl/gsl_randist.h"
      |          ^~~~~~~~~~~~~~~~~~~
compilation terminated.
common/VariableManager.C:149:33: warning: "/*" within comment [-Wcomment]
  149 |                                 /*else if(tokCnt==4)
      |                                  
common/FactorGraph.C:156:17: warning: "/*" within comment [-Wcomment]
  156 |                 /*for(INTDBLMAP_ITER idIter=sFactor->goodMBIDs.begin();idIter!=sFactor->goodMBIDs.end();idIter++)
      |                  
common/Graph.C: In member function ‘int Graph::showDegreeDist(const char*)’:
common/Graph.C:277:1: warning: no return statement in function returning non-void [-Wreturn-type]
  277 | }
      | ^
In file included from common/Matrix.C:15:
common/Matrix.H:6:10: fatal error: gsl/gsl_matrix.h: No such file or directory
    6 | #include <gsl/gsl_matrix.h>
      |          ^~~~~~~~~~~~~~~~~~
compilation terminated.
common/PotentialManager.C:18:10: fatal error: gsl/gsl_blas.h: No such file or directory
   18 | #include <gsl/gsl_blas.h>
      |          ^~~~~~~~~~~~~~~~
compilation terminated.
common/Utils.C: In static member function ‘static std::vector<std::__cxx11::basic_string<char> > Utils::splitLines(std::string, int)’:
common/Utils.C:67:13: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::__cxx11::basic_string<char>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
   67 |     while(i < s.length())
      |           ~~^~~~~~~~~~~~
common/Variable.C: In member function ‘int Variable::setValues(INTVECT&)’:
common/Variable.C:61:22: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::vector<int>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
   61 |         for(int i=0;i<aValSet.size();i++)
      |                     ~^~~~~~~~~~~~~~~
common/Variable.C: In member function ‘bool Variable::isValidValue(int)’:
common/Variable.C:86:17: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::vector<int>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
   86 |         while((i<valueSet.size()) && (!found))
      |                ~^~~~~~~~~~~~~~~~
common/Variable.C: In member function ‘int Variable::initEvidence(INTDBLMAP&)’:
common/Variable.C:101:22: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::vector<int>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
  101 |         for(int i=0;i<valueSet.size();i++)
      |                     ~^~~~~~~~~~~~~~~~
orthomapsparser/MappedOrthogroupReader.C: In member function ‘int MappedOrthogroupReader::readFile(const char*)’:
orthomapsparser/MappedOrthogroupReader.C:54:19: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::__cxx11::basic_string<char>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
   54 |         if(bufflen<=buffstr.length())
      |            ~~~~~~~^~~~~~~~~~~~~~~~~~
orthomapsparser/MappedOrthogroupReader.C: In member function ‘int MappedOrthogroupReader::addMembers(char*, MappedOrthogroup*)’:
orthomapsparser/MappedOrthogroupReader.C:184:10: warning: unused variable ‘debug’ [-Wunused-variable]
  184 |     bool debug = false;  // can set this to true in the debugger to display useful stuff
      |          ^~~~~
orthomapsparser/MappedOrthogroupReader.C: In member function ‘int MappedOrthogroupReader::generateGeneOrthoMap()’:
orthomapsparser/MappedOrthogroupReader.C:263:30: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::vector<std::__cxx11::basic_string<char> >::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
  263 |         for(int sIter=0;sIter<members.size();sIter++) //map<string,string>::iterator
      |                         ~~~~~^~~~~~~~~~~~~~~
mak
```e: *** [Makefile:10: condSpecLearner] Error 1
sroyyors commented 6 months ago

hi Moses, Just like you have included the lib path /work/WORK/binaries/gsl/lib/ for the -L option you also need to provide the include path for gsl using another -I option. Based on your path above, I believe you can do -I /work/WORK/binaries/gsl/include

This should get rid of the gsl specific errors.

The others seem to be compiler version specific. scMTNI was compiled with g++ 4.8.5. Can you tell us what you get if you do:

g++ --version

on the command line?

mapo121 commented 6 months ago

g++ (GCC) 11.2.0
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
sroyyors commented 6 months ago

Thanks Moses, I think we will load the appropriate compiler on our machines and see if we can fix the issues for you.

mapo121 commented 6 months ago

Might I suggest that you use Docker? I have Docker installed, could you export a Dockerhub that people/I could install locally on their computer.

I've written my own Dockerfile before, but you would know the "dependencies" you would need to run scMTNI.

https://hub.docker.com/

sroyyors commented 6 months ago

hi Moses, Docker is useful when the software needs a lot of complex dependencies. We don't think scMTNI has so many dependencies. All it needs really is gsl. This design was deliberate so that users can install and use scMTNI without going inside a blackhole of packages after packages.

I looked again above at the errors you get. It seems the error is only the missing paths for gsl/include and gsl/lib. You have already installed gsl so all you need to do is update the -I flag and the -L flag as we described before. The other messages are just warnings. I see these when I upgrade the compiler. But there are no errors. Can you try setting the path and see if you get the scMTNI executable?

mapo121 commented 6 months ago

I see only warnings now -

For reference this is the makefile here:

INCLPATH2 = common/
INCLPATH3 = orthomapsparser/
INCLPATH4 = <gsl_lib_here>/gsl/lib/ 
INCLPATH5 =  <gsl_lib_here>/gsl/include/
CC=g++
CFLAGS = -g -std=gnu++14 -gdwarf-2

condSpecLearner: $(SRC)
    $(CC) -Wall $(SRC) -I $(INCLPATH2) -I $(INCLPATH3) -L $(INCLPATH4) -I $(INCLPATH5) $(LFLAG) $(CFLAGS) -o scMTNI