shogun-toolbox / shogun

Shōgun
http://shogun-toolbox.org
BSD 3-Clause "New" or "Revised" License
3.03k stars 1.04k forks source link

Check for includes in header files #2557

Closed karlnapf closed 7 years ago

karlnapf commented 10 years ago

What about adding a simple check to cmake that scans all Shogun header files for includes that are not coming from Shogun? This way, we could for example avoid to have Eigen3 includes in headers -- Shogun just wont compile in that case. Would maybe save us some trouble

In fact, this is also an entrace task: remove all non-shogun includes from header files and move to implementation .cpp files

karlnapf commented 10 years ago

@tklein23 could you post a shell magic script for that here? something that output the filenames of header files that include something else than <shogun/ ..... >

srgnuclear commented 10 years ago

hi.. I am working on this .. should i go through each header file or is their some other approach??

iglesias commented 10 years ago

@srgnuclear, a script that goes through the header files and reports everything included that is not <shogun/...> will definitely help.

However, I think this is not so straightforward. We have some header files, like our entry point for eigen3 in mathematics which includes Eigen3 headers.

Maybe we could start by checking that SWIG is not going through non-Shogun files. I am curious about whether this would make any impact in compilation time/memory. I think it won't.

srgnuclear commented 10 years ago

@iglesias, k i will look up the script. In the meantime i manually went through header files in src and found some includes apart from < shogun/... > like < vector > ,< stdio.h > ,< glpk.h > ,< cmath > ,< cassert > ,< math.h > ,< limits.h > ,< ctype.h > ,< string.h > ,< stdlib.h > ,< time.h > etc do these also have to be removed because these are some basic includes used frequently.

Also if this is not having considerable impact should i continue with it?

iglesias commented 10 years ago

On 31 October 2014 14:29, Saurabh Goyal notifications@github.com wrote:

@iglesias https://github.com/iglesias, k i will look up the script. In the meantime i manually went through header files in src and found some include apart from like < vector > ,< stdio.h > ,< glpk.h > ,< cmath > ,< cassert > ,< math.h > ,< limits.h > ,< ctype.h > ,< string.h > ,< stdlib.h

,< time.h > etc do these also have to be removed because these are some basic includes used frequently.

I would say the following:

If possible, try to move these includes from header files to their corresponding implementation (cpp) files. This will be possible to do when (i) they are not necessary because no method or data structure defined in those included files is used in the header; (ii) the piece of code that requires any of those includes can me moved to the cpp file. The latter might be a bit trickier to solve when dealing with template classes, so I would focus on non-templates firstly.

Also if this is not having considerable impact should i continue with it?

Well, the thing is that we (at least I) don't even know what the impact these changes might have on the resources (time and mem) used by make during compilation. I understand that the main motivation of doing this is swig. Thus, what you can do to quickly get a feel for it is to guard all these includes by #ifndef SWIG // SWIG should skip this ... #endif and compare compilation resources before and after these guards are introduced.

Does that make sense to you?

— Reply to this email directly or view it on GitHub https://github.com/shogun-toolbox/shogun/issues/2557#issuecomment-61259693 .

srgnuclear commented 10 years ago

yup a lot better now .. i ll work on it and keep you posted ..

karlnapf commented 10 years ago

I think finding non Shogun includes in all header files should be a short one liner in bash..... @iglesias @tklein23 will produce this in like 10 secs :)

srgnuclear commented 10 years ago

Can we have that one line command here??. Because going through each header file will be very tedious.

karlnapf commented 10 years ago

Here you go

find . -name '*.h' | xargs grep '#include' | uniq | grep -v '<shogun/'

produces a lot of hints. Not all of those need to be remove, but most I would say. You dont look at the lib things for now, but start with more obvious things such as classifiers. For sure, none of the algorithm classes would have a non-shogun header included. Let us know how things go

Oh and very important, please do one PR per class. Dont mix up too many things, we want travis to make sure everything compiles before merging such things. Run all tests locally before sending PRs

./lib/slep/tree/altra.h:#include <stdio.h>
./lib/slep/tree/altra.h:#include <stdlib.h>
./lib/slep/tree/altra.h:#include <math.h>
./lib/slep/tree/altra.h:#include <string.h>
./lib/slep/tree/general_altra.h:#include <stdio.h>
./lib/slep/tree/general_altra.h:#include <stdlib.h>
./lib/slep/tree/general_altra.h:#include <math.h>
./lib/slep/tree/general_altra.h:#include <string.h>
./lib/slep/overlapping/overlapping.h:#include <stdio.h>
./lib/slep/overlapping/overlapping.h:#include <stdlib.h>
./lib/slep/overlapping/overlapping.h:#include <math.h>
./lib/slep/overlapping/overlapping.h:#include <string.h>
./lib/slep/slep_options.h:#include <stdlib.h>
./lib/slep/order/orderTree.h:#include <stdlib.h>
./lib/slep/order/orderTree.h:#include <stdio.h>
./lib/slep/order/orderTree.h:#include <time.h>
./lib/slep/order/orderTree.h:#include <math.h>
./lib/slep/order/sequence.h:#include <stdlib.h>
./lib/slep/order/sequence.h:#include <stdio.h>
./lib/slep/order/sequence.h:#include <time.h>
./lib/slep/order/sequence.h:#include <math.h>
./lib/slep/q1/ep21d.h:#include <stdlib.h>
./lib/slep/q1/ep21d.h:#include <stdio.h>
./lib/slep/q1/ep21d.h:#include <time.h>
./lib/slep/q1/ep21d.h:#include <math.h>
./lib/slep/q1/eppVector.h:#include <stdlib.h>
./lib/slep/q1/eppVector.h:#include <stdio.h>
./lib/slep/q1/eppVector.h:#include <time.h>
./lib/slep/q1/eppVector.h:#include <math.h>
./lib/slep/q1/ep1R.h:#include <stdlib.h>
./lib/slep/q1/ep1R.h:#include <stdio.h>
./lib/slep/q1/ep1R.h:#include <time.h>
./lib/slep/q1/ep1R.h:#include <math.h>
./lib/slep/q1/epsp.h:#include <stdlib.h>
./lib/slep/q1/epsp.h:#include <stdio.h>
./lib/slep/q1/epsp.h:#include <time.h>
./lib/slep/q1/epsp.h:#include <math.h>
./lib/slep/q1/epsgLasso.h:#include <stdlib.h>
./lib/slep/q1/epsgLasso.h:#include <stdio.h>
./lib/slep/q1/epsgLasso.h:#include <time.h>
./lib/slep/q1/epsgLasso.h:#include <math.h>
./lib/slep/q1/eppVectorR.h:#include <stdlib.h>
./lib/slep/q1/eppVectorR.h:#include <stdio.h>
./lib/slep/q1/eppVectorR.h:#include <time.h>
./lib/slep/q1/eppVectorR.h:#include <math.h>
./lib/slep/q1/ep21R.h:#include <stdlib.h>
./lib/slep/q1/ep21R.h:#include <stdio.h>
./lib/slep/q1/ep21R.h:#include <time.h>
./lib/slep/q1/ep21R.h:#include <math.h>
./lib/slep/SpInvCoVa/invCov.h:#include <stdlib.h>
./lib/slep/SpInvCoVa/invCov.h:#include <stdio.h>
./lib/slep/SpInvCoVa/invCov.h:#include <time.h>
./lib/slep/SpInvCoVa/invCov.h:#include <math.h>
./lib/memory.h:#include <new>
./lib/OpenCV/SG2CVFactory.h:#include <opencv2/core/core.hpp>
./lib/OpenCV/CV2SGFactory.h:#include <opencv2/core/core.hpp>
./lib/OpenCV/OpenCVTypeName.h:#include <opencv2/core/core.hpp>
./lib/v_array.h:#include <stdlib.h>
./lib/Set.h:#include <cstdio>
./lib/RefCount.h:#include <atomic>
./lib/external/SFMT/SFMT.h:#include <stdio.h>
./lib/external/SFMT/SFMT.h:#include <assert.h>
./lib/external/SFMT/SFMT.h:  #include <inttypes.h>
./lib/external/SFMT/SFMT.h:  #include <emmintrin.h>
./lib/external/PMurHash.h:  #include <stdint.h>
./lib/external/PMurHash.h:  #include  <limits.h>
./lib/external/libqp.h:#include <math.h>
./lib/external/brent.h:#include <vector>
./lib/external/dSFMT/dSFMT.h:#include <stdio.h>
./lib/external/dSFMT/dSFMT.h:#include <assert.h>
./lib/common.h:#include <stdlib.h>
./lib/common.h:#include <stdio.h>
./lib/common.h:#include <sys/types.h>
./lib/common.h:#include <stdint.h>
./lib/common.h:#include <inttypes.h>
./lib/common.h:#include <complex>
./lib/GPUVector.h:#include <memory>
./lib/Time.h:#include <sys/time.h>
./lib/Time.h:#include <time.h>
./lib/JLCoverTree.h:#include<math.h>
./lib/JLCoverTree.h:#include<stdio.h>
./lib/JLCoverTree.h:#include<assert.h>
./lib/malsar/malsar_options.h:#include <stdlib.h>
./lib/GPUMatrix.h:#include <memory>
./lib/Signal.h:#include <signal.h>
./lib/Trie.h:#include <string.h>
./lib/Cache.h:#include <stdlib.h>
./lib/Map.h:#include <cstdio>
./base/init.h:#include <stdio.h>
./loss/LossFunction.h:#include <math.h>
./transfer/domain_adaptation/DomainAdaptationSVMLinear.h:#include <stdio.h>
./transfer/domain_adaptation/DomainAdaptationSVM.h:#include <stdio.h>
./transfer/multitask/MultitaskKernelPlifNormalizer.h:#include <algorithm>
./transfer/multitask/MultitaskKernelPlifNormalizer.h:#include <vector>
./transfer/multitask/MultitaskKernelTreeNormalizer.h:#include <algorithm>
./transfer/multitask/MultitaskKernelTreeNormalizer.h:#include <map>
./transfer/multitask/MultitaskKernelTreeNormalizer.h:#include <set>
./transfer/multitask/MultitaskKernelTreeNormalizer.h:#include <deque>
./transfer/multitask/MultitaskKernelTreeNormalizer.h:#include <vector>
./transfer/multitask/MultitaskKernelNormalizer.h:#include <algorithm>
./transfer/multitask/MultitaskKernelNormalizer.h:#include <vector>
./transfer/multitask/MultitaskLinearMachine.h:#include <vector>
./transfer/multitask/MultitaskLinearMachine.h:#include <set>
./transfer/multitask/MultitaskKernelMaskNormalizer.h:#include <set>
./transfer/multitask/MultitaskKernelMaskNormalizer.h:#include <string>
./transfer/multitask/MultitaskKernelMaskNormalizer.h:#include <vector>
./transfer/multitask/MultitaskKernelMklNormalizer.h:#include <algorithm>
./transfer/multitask/MultitaskKernelMklNormalizer.h:#include <string>
./transfer/multitask/MultitaskLogisticRegression.h:#include <vector>
./transfer/multitask/MultitaskLogisticRegression.h:#include <set>
./transfer/multitask/LibLinearMTL.h:#include <map>
./transfer/multitask/MultitaskKernelMaskPairNormalizer.h:#include <string>
./transfer/multitask/MultitaskKernelMaskPairNormalizer.h:#include <vector>
./transfer/multitask/MultitaskKernelMaskPairNormalizer.h:#include <utility>
./evaluation/ClusteringEvaluation.h:#include <vector>
./distributions/HMM.h:#include <stdio.h>
./machine/LinearMachine.h:#include <stdio.h>
./machine/KernelMachine.h:#include <stdio.h>
./machine/OnlineLinearMachine.h:#include <stdio.h>
./machine/DistanceMachine.h:#include <stdio.h>
./optimization/liblinear/shogun_liblinear.h:#include <vector>
./regression/svr/LibSVR.h:#include <stdio.h>
./regression/LeastAngleRegression.h:#include <vector>
./mathematics/eigen3.h: #include <Eigen/Eigen>
./mathematics/eigen3.h: #include <Eigen/Dense>
./mathematics/eigen3.h:     #include <Eigen/Sparse>
./mathematics/eigen3.h:     #include <unsupported/Eigen/SparseExtra>
./mathematics/linalg/internal/opencl_util.h:#include <viennacl/ocl/backend.hpp>
./mathematics/linalg/internal/opencl_util.h:#include <viennacl/ocl/kernel.hpp>
./mathematics/linalg/internal/opencl_util.h:#include <viennacl/ocl/program.hpp>
./mathematics/linalg/internal/opencl_util.h:#include <viennacl/ocl/utils.hpp>
./mathematics/linalg/internal/opencl_util.h:#include <viennacl/tools/tools.hpp>
./mathematics/linalg/internal/opencl_util.h:#include <string>
./mathematics/linalg/internal/implementation/Sum.h:#include <string>
./mathematics/linalg/internal/implementation/Max.h:#include <string>
./mathematics/linalg/internal/implementation/MatrixProduct.h:#include <viennacl/linalg/prod.hpp>
./mathematics/linalg/internal/implementation/MatrixProduct.h:#include <viennacl/matrix.hpp>
./mathematics/linalg/internal/implementation/Add.h:#include <viennacl/linalg/matrix_operations.hpp>
./mathematics/linalg/internal/implementation/Add.h:#include <viennacl/linalg/vector_operations.hpp>
./mathematics/linalg/internal/implementation/ElementwiseProduct.h:#include <viennacl/linalg/matrix_operations.hpp>
./mathematics/linalg/internal/implementation/Scale.h:#include <viennacl/linalg/matrix_operations.hpp>
./mathematics/linalg/internal/implementation/Scale.h:#include <viennacl/linalg/vector_operations.hpp>
./mathematics/linalg/internal/implementation/Dot.h:#include <viennacl/linalg/inner_prod.hpp>
./mathematics/Statistics.h:#include <math.h>
./mathematics/lapack.h:#include <mkl_cblas.h>
./mathematics/lapack.h:#include <mkl_lapack.h>
./mathematics/lapack.h:#include <Accelerate/Accelerate.h>
./mathematics/lapack.h:#include <cblas.h>
./mathematics/lapack.h:#include <acml.h>
./mathematics/lapack.h:#include <clapack.h>
./mathematics/Random.h:#include <limits>
./mathematics/Math.h:#include <math.h>
./mathematics/Math.h:#include <stdio.h>
./mathematics/Math.h:#include <float.h>
./mathematics/Math.h:#include <sys/types.h>
./mathematics/Math.h:#include <unistd.h>
./mathematics/Math.h:#include <pthread.h>
./mathematics/Math.h:#include <ieeefp.h>
./mathematics/munkres.h:#include <list>
./mathematics/munkres.h:#include <utility>
./mathematics/Mosek.h:#include <mosek.h>
./mathematics/Cplex.h:#include <ilcplex/cplex.h>
./mathematics/JacobiEllipticFunctions.h:#include <limits>
./mathematics/JacobiEllipticFunctions.h:#include <math.h>
./mathematics/JacobiEllipticFunctions.h:#include <arprec/mp_real.h>
./mathematics/JacobiEllipticFunctions.h:#include <arprec/mp_complex.h>
./preprocessor/PNorm.h:#include <stdio.h>
./preprocessor/HomogeneousKernelMap.h:#include <stdio.h>
./preprocessor/LogPlusOne.h:#include <stdio.h>
./preprocessor/SortUlongString.h:#include <stdio.h>
./preprocessor/PruneVarSubMean.h:#include <stdio.h>
./preprocessor/SparsePreprocessor.h:#include <stdio.h>
./preprocessor/SumOne.h:#include <stdio.h>
./preprocessor/SortWordString.h:#include <stdio.h>
./preprocessor/NormOne.h:#include <stdio.h>
./preprocessor/RandomFourierGaussPreproc.h:#include <vector>
./preprocessor/RandomFourierGaussPreproc.h:#include <algorithm>
./kernel/string/SpectrumMismatchRBFKernel.h:#include <string>
./kernel/string/SpectrumMismatchRBFKernel.h:#include <vector>
./kernel/string/OligoStringKernel.h:#include <vector>
./kernel/string/OligoStringKernel.h:#include <string>
./kernel/string/SpectrumRBFKernel.h:#include <vector> // profile
./kernel/string/SpectrumRBFKernel.h:#include <string> // profile
./clustering/Hierarchical.h:#include <stdio.h>
./clustering/KMeans.h:#include <stdio.h>
./clustering/GMM.h:#include <vector>
./multiclass/KNN.h:#include <stdio.h>
./multiclass/GMNPLib.h:#include <math.h>
./multiclass/GMNPLib.h:#include <limits.h>
./multiclass/ecoc/ECOCDiscriminantEncoder.h:#include <vector>
./multiclass/ecoc/ECOCDiscriminantEncoder.h:#include <set>
./multiclass/tree/ConditionalProbabilityTree.h:#include <map>
./multiclass/tree/RelaxedTree.h:#include <utility>
./multiclass/tree/RelaxedTree.h:#include <vector>
./multiclass/tree/VwConditionalProbabilityTree.h:#include <map>
./multiclass/LaRank.h:#include <ctime>
./multiclass/LaRank.h:#include <vector>
./multiclass/LaRank.h:#include <algorithm>
./multiclass/LaRank.h:#include <sys/time.h>
./multiclass/LaRank.h:#include <set>
./multiclass/LaRank.h:#include <map>
./multiclass/ScatterSVM.h:#include <stdio.h>
./neuralnets/DeepBeliefNetwork.h:#include <lib/SGMatrixList.h>
./io/ProtobufFile.h:#include <google/protobuf/message.h>
./io/SerializableXmlFile.h:#include <libxml/parser.h>
./io/SerializableXmlFile.h:#include <libxml/tree.h>
./io/LineReader.h:#include <stdio.h>
./io/MLDataHDF5File.h:#include <hdf5.h>
./io/SerializableFile.h:#include <stdio.h>
./io/streaming/ParseBuffer.h:#include <pthread.h>
./io/streaming/InputParser.h:#include <pthread.h>
./io/SimpleFile.h:#include <stdio.h>
./io/SimpleFile.h:#include <string.h>
./io/SimpleFile.h:#include <sys/mman.h>
./io/BinaryStream.h:#include <stdio.h>
./io/BinaryStream.h:#include <sys/stat.h>
./io/SGIO.h:#include <stdio.h>
./io/SGIO.h:#include <string.h>
./io/SGIO.h:#include <dirent.h>
./io/SGIO.h:#include <locale.h>
./io/SGIO.h:#include <sys/types.h>
./io/SGIO.h:#include <unistd.h>
./io/SGIO.h:#include <Availability.h>
./io/SerializableHdf5File.h:#include <hdf5.h>
./io/HDF5File.h:#include <hdf5.h>
./io/MemoryMappedFile.h:#include <stdio.h>
./io/MemoryMappedFile.h:#include <string.h>
./io/MemoryMappedFile.h:#include <sys/mman.h>
./io/MemoryMappedFile.h:#include <sys/stat.h>
./io/MemoryMappedFile.h:#include <sys/types.h>
./io/MemoryMappedFile.h:#include <fcntl.h>
./io/MemoryMappedFile.h:#include <unistd.h>
./io/protobuf/ShogunVersion.pb.h:#include <string>
./io/protobuf/ShogunVersion.pb.h:#include <google/protobuf/stubs/common.h>
./io/protobuf/ShogunVersion.pb.h:#include <google/protobuf/generated_message_util.h>
./io/protobuf/ShogunVersion.pb.h:#include <google/protobuf/message.h>
./io/protobuf/ShogunVersion.pb.h:#include <google/protobuf/repeated_field.h>
./io/protobuf/ShogunVersion.pb.h:#include <google/protobuf/extension_set.h>
./io/protobuf/ShogunVersion.pb.h:#include <google/protobuf/generated_enum_reflection.h>
./io/protobuf/ShogunVersion.pb.h:#include <google/protobuf/unknown_field_set.h>
./io/protobuf/Chunks.pb.h:#include <string>
./io/protobuf/Chunks.pb.h:#include <google/protobuf/stubs/common.h>
./io/protobuf/Chunks.pb.h:#include <google/protobuf/generated_message_util.h>
./io/protobuf/Chunks.pb.h:#include <google/protobuf/message.h>
./io/protobuf/Chunks.pb.h:#include <google/protobuf/repeated_field.h>
./io/protobuf/Chunks.pb.h:#include <google/protobuf/extension_set.h>
./io/protobuf/Chunks.pb.h:#include <google/protobuf/unknown_field_set.h>
./io/protobuf/Headers.pb.h:#include <string>
./io/protobuf/Headers.pb.h:#include <google/protobuf/stubs/common.h>
./io/protobuf/Headers.pb.h:#include <google/protobuf/generated_message_util.h>
./io/protobuf/Headers.pb.h:#include <google/protobuf/message.h>
./io/protobuf/Headers.pb.h:#include <google/protobuf/repeated_field.h>
./io/protobuf/Headers.pb.h:#include <google/protobuf/extension_set.h>
./io/protobuf/Headers.pb.h:#include <google/protobuf/unknown_field_set.h>
./io/SerializableJsonFile.h:#include <json.h>
./metric/LMNNImpl.h:#include <Eigen/Dense>
./metric/LMNNImpl.h:#include <set>
./metric/LMNNImpl.h:#include <vector>
./distance/Distance.h:#include <stdio.h>
./structure/CCSOSVM.h:#include <mosek.h>
./structure/DynProg.h:#include <stdio.h>
./structure/DynProg.h:#include <limits.h>
./structure/BeliefPropagation.h:#include <vector>
./structure/BeliefPropagation.h:#include <set>
./structure/BeliefPropagation.h:    #include <unordered_map>
./structure/BeliefPropagation.h:    #include <tr1/unordered_map>
./classifier/NearestCentroid.h:#include <stdio.h>
./classifier/AveragedPerceptron.h:#include <stdio.h>
./classifier/LPM.h:#include <stdio.h>
./classifier/svm/GNPPLib.h:#include <math.h>
./classifier/svm/GNPPLib.h:#include <limits.h>
./classifier/svm/SVMLight.h:#include <stdio.h>
./classifier/svm/SVMLight.h:#include <ctype.h>
./classifier/svm/SVMLight.h:#include <string.h>
./classifier/svm/SVMLight.h:#include <stdlib.h>
./classifier/svm/SVMLight.h:#include <time.h>
./classifier/svm/QPBSVMLib.h:#include <math.h>
./classifier/svm/QPBSVMLib.h:#include <limits.h>
./classifier/svm/GPBTSVM.h:#include <stdio.h>
./classifier/svm/LibSVMOneClass.h:#include <stdio.h>
./classifier/LPBoost.h:#include <stdio.h>
./classifier/mkl/MKLMulticlass.h:#include <vector>
./classifier/mkl/MKLMulticlassGLPK.h:#include <vector>
./classifier/mkl/MKLMulticlassGradient.h:#include <vector>
./classifier/mkl/MKLMulticlassGradient.h:#include <cmath>
./classifier/mkl/MKLMulticlassGradient.h:#include <cassert>
./classifier/mkl/MKL.h:#include <glpk.h>
./classifier/mkl/MKL.h:#include <ilcplex/cplex.h>
./classifier/mkl/MKLMulticlassOptimizationBase.h:#include <vector>
./classifier/Perceptron.h:#include <stdio.h>
srgnuclear commented 10 years ago

sure ..!!

srgnuclear commented 10 years ago

I transfered all non shogun includes from header files to .cpp in classifier. After doing this when i compiled i got errors like -

/_In file included from /home/saurabh/shogun-install/shogun-3.1.1/src/shogun/../shogun/classifier/mkl/MKLMulticlassGLPK.h:18:0, from /home/saurabh/shogun-install/shogun-3.1.1/src/shogun/../shogun/classifier/mkl/MKLMulticlass.h:21, from /home/saurabh/shogun-install/shogun-3.1.1/src/shogun/evaluation/CrossValidationPrintOutput.cpp:18: /home/saurabh/shogun-install/shogun-3.1.1/src/shogun/../shogun/classifier/mkl/MKLMulticlassOptimizationBase.h:52:35: error: ‘vector’ in namespace ‘std’ does not name a type virtual void addconstraint(const ::std::vector & normw2, ^ /home/saurabh/shogun-install/shogun-3.1.1/src/shogun/../shogun/classifier/mkl/MKLMulticlassOptimizationBase.h:52:42: error: ISO C++ forbids declaration of ‘parameter’ with no type [-fpermissive] virtual void addconstraint(const ::std::vector & normw2, ^ /home/saurabh/shogun-install/shogun-3.1.1/src/shogun/../shogun/classifier/mkl/MKLMulticlassOptimizationBase.h:52:48: error: expected ‘,’ or ‘...’ before ‘<’ token virtual void addconstraint(const ::std::vector & normw2, ^ /home/saurabh/shogun-install/shogun-3.1.1/src/shogun/../shogun/classifier/mkl/MKLMulticlassOptimizationBase.h:60:35: error: ‘std::vector’ has not been declared virtual void computeweights(std::vector & weights2); ^ /home/saurabh/shogun-install/shogun-3.1.1/src/shogun/../shogun/classifier/mkl/MKLMulticlassOptimizationBase.h:60:41: error: expected ‘,’ or ‘...’ before ‘<’ token virtual void computeweights(std::vector & weights2); ^ In file included from /home/saurabh/shogun-install/shogun-3.1.1/src/shogun/../shogun/classifier/mkl/MKLMulticlass.h:21:0, from /home/saurabh/shogun-install/shogun-3.1.1/src/shogun/evaluation/CrossValidationPrintOutput.cpp:18: /home/saurabh/shogun-install/shogun-3.1.1/src/shogun/../shogun/classifier/mkl/MKLMulticlassGLPK.h:55:35: error: ‘vector’ in namespace ‘std’ does not name a type virtual void addconstraint(const ::std::vector & normw2, ^ /home/saurabh/shogun-install/shogun-3.1.1/src/shogun/../shogun/classifier/mkl/MKLMulticlassGLPK.h:55:42: error: ISO C++ forbids declaration of ‘parameter’ with no type [-fpermissive] virtual void addconstraint(const ::std::vector & normw2, ^ /home/saurabh/shogun-install/shogun-3.1.1/src/shogun/../shogun/classifier/mkl/MKLMulticlassGLPK.h:55:48: error: expected ‘,’ or ‘...’ before ‘<’ token virtual void addconstraint(const ::std::vector & normw2, ^ /home/saurabh/shogun-install/shogun-3.1.1/src/shogun/../shogun/classifier/mkl/MKLMulticlassGLPK.h:63:35: error: ‘std::vector’ has not been declared virtual void computeweights(std::vector & weights2); ^ /home/saurabh/shogun-install/shogun-3.1.1/src/shogun/../shogun/classifier/mkl/MKLMulticlassGLPK.h:63:41: error: expected ‘,’ or ‘...’ before ‘<’ token virtual void computeweights(std::vector & weights2); ^ In file included from /home/saurabh/shogun-install/shogun-3.1.1/src/shogun/../shogun/classifier/mkl/MKLMulticlass.h:22:0, from /home/saurabh/shogun-install/shogun-3.1.1/src/shogun/evaluation/CrossValidationPrintOutput.cpp:18: /home/saurabh/shogun-install/shogun-3.1.1/src/shogun/../shogun/classifier/mkl/MKLMulticlassGradient.h:66:35: error: ‘vector’ in namespace ‘std’ does not name a type virtual void addconstraint(const ::std::vector & normw2, ^ /home/saurabh/shogun-install/shogun-3.1.1/src/shogun/../shogun/classifier/mkl/MKLMulticlassGradient.h:66:42: error: ISO C++ forbids declaration of ‘parameter’ with no type [-fpermissive] virtual void addconstraint(const ::std::vector & normw2, ^ /home/saurabh/shogun-install/shogun-3.1.1/src/shogun/../shogun/classifier/mkl/MKLMulticlassGradient.h:66:48: error: expected ‘,’ or ‘...’ before ‘<’ token virtual void addconstraint(const ::std::vector & normw2, ^ /home/saurabh/shogun-install/shogun-3.1.1/src/shogun/../shogun/classifier/mkl/MKLMulticlassGradient.h:74:35: error: ‘std::vector’ has not been declared virtual void computeweights(std::vector & weights2); ^ /home/saurabh/shogun-install/shogun-3.1.1/src/shogun/../shogun/classifier/mkl/MKLMulticlassGradient.h:74:41: error: expected ‘,’ or ‘...’ before ‘<’ token virtual void computeweights(std::vector & weights2); ^ /home/saurabh/shogun-install/shogun-3.1.1/src/shogun/../shogun/classifier/mkl/MKLMulticlassGradient.h:91:24: error: ‘std::vector’ has not been declared void linesearch2(std::vector & finalbeta,const std::vector & oldweights); ^ /home/saurabh/shogun-install/shogun-3.1.1/src/shogun/../shogun/classifier/mkl/MKLMulticlassGradient.h:91:30: error: expected ‘,’ or ‘...’ before ‘<’ token void linesearch2(std::vector & finalbeta,const std::vector & oldweights); ^ /home/saurabh/shogun-install/shogun-3.1.1/src/shogun/../shogun/classifier/mkl/MKLMulticlassGradient.h:99:24: error: ‘std::vector’ has not been declared void genbetas( ::std::vector & weights ,const ::std::vector & gammas); ^ /home/saurabh/shogun-install/shogun-3.1.1/src/shogun/../shogun/classifier/mkl/MKLMulticlassGradient.h:99:30: error: expected ‘,’ or ‘...’ before ‘<’ token void genbetas( ::std::vector & weights ,const ::std::vector & gammas); ^ In file included from /home/saurabh/shogun-install/shogun-3.1.1/src/shogun/../shogun/classifier/mkl/MKLMulticlass.h:22:0, from /home/saurabh/shogun-install/shogun-3.1.1/src/shogun/evaluation/CrossValidationPrintOutput.cpp:18: /home/saurabh/shogun-install/shogun-3.1.1/src/shogun/../shogun/classifier/mkl/MKLMulticlassGradient.h:108:32: error: ‘std::vector’ has not been declared void gengammagradient( ::std::vector & gammagradient ,const ::std::vector & gammas,const int32_t dim); ^ /home/saurabh/shogun-install/shogun-3.1.1/src/shogun/../shogun/classifier/mkl/MKLMulticlassGradient.h:108:38: error: expected ‘,’ or ‘...’ before ‘<’ token void gengammagradient( ::std::vector & gammagradient ,const ::std::vector & gammas,const int32_t dim); ^ /home/saurabh/shogun-install/shogun-3.1.1/src/shogun/../shogun/classifier/mkl/MKLMulticlassGradient.h:116:29: error: ‘vector’ in namespace ‘std’ does not name a type float64_t objectives(const ::std::vector & weights, const int32_t index); ^ /home/saurabh/shogun-install/shogun-3.1.1/src/shogun/../shogun/classifier/mkl/MKLMulticlassGradient.h:116:36: error: ISO C++ forbids declaration of ‘parameter’ with no type [-fpermissive] float64_t objectives(const ::std::vector & weights, const int32_t index); ^ /home/saurabh/shogun-install/shogun-3.1.1/src/shogun/../shogun/classifier/mkl/MKLMulticlassGradient.h:116:42: error: expected ‘,’ or ‘...’ before ‘<’ token float64_t objectives(const ::std::vector & weights, const int32_t index); ^ /home/saurabh/shogun-install/shogun-3.1.1/src/shogun/../shogun/classifier/mkl/MKLMulticlassGradient.h:124:23: error: ‘std::vector’ has not been declared void linesearch(std::vector & finalbeta,const std::vector & oldweights); ^ /home/saurabh/shogun-install/shogun-3.1.1/src/shogun/../shogun/classifier/mkl/MKLMulticlassGradient.h:124:29: error: expected ‘,’ or ‘...’ before ‘<’ token void linesearch(std::vector & finalbeta,const std::vector & oldweights); ^ /home/saurabh/shogun-install/shogun-3.1.1/src/shogun/../shogun/classifier/mkl/MKLMulticlassGradient.h:132:2: error: ‘vector’ in namespace ‘std’ does not name a type ::std::vector< ::std::vector > normsofsubkernels; ^ /home/saurabh/shogun-install/shogun-3.1.1/src/shogun/../shogun/classifier/mkl/MKLMulticlassGradient.h:134:2: error: ‘vector’ in namespace ‘std’ does not name a type ::std::vector< float64_t > sumsofalphas ; ^ In file included from /home/saurabh/shogun-install/shogun-3.1.1/src/shogun/evaluation/CrossValidationPrintOutput.cpp:18:0: /home/saurabh/shogun-install/shogun-3.1.1/src/shogun/../shogun/classifier/mkl/MKLMulticlass.h:138:34: error: ‘vector’ in namespace ‘std’ does not name a type void addingweightsstep( const std::vector & curweights); ^ /home/saurabh/shogun-install/shogun-3.1.1/src/shogun/../shogun/classifier/mkl/MKLMulticlass.h:138:39: error: ISO C++ forbids declaration of ‘parameter’ with no type [-fpermissive] void addingweightsstep( const std::vector & curweights); ^ /home/saurabh/shogun-install/shogun-3.1.1/src/shogun/../shogun/classifier/mkl/MKLMulticlass.h:138:45: error: expected ‘,’ or ‘...’ before ‘<’ token void addingweightsstep( const std::vector & curweights); ^ In file included from /home/saurabh/shogun-install/shogun-3.1.1/src/shogun/evaluation/CrossValidationPrintOutput.cpp:18:0: /home/saurabh/shogun-install/shogun-3.1.1/src/shogun/../shogun/classifier/mkl/MKLMulticlass.h:179:4: error: ‘vector’ in namespace ‘std’ does not name a type ::std::vector< std::vector< float64_t> > weightshistory; ^ /home/saurabh/shogun-install/shogun-3.1.1/src/shogun/../shogun/classifier/mkl/MKLMulticlass.h:200:4: error: ‘vector’ in namespace ‘std’ does not name a type std::vector normweightssquared; ^ /home/saurabh/shogun-install/shogun-3.1.1/src/shogun/../shogun/classifier/mkl/MKLMulticlass.h:203:4: error: ‘vector’ in namespace ‘std’ does not name a type std::vector oldnormweightssquared; ^ make[2]: _\ [src/shogun/CMakeFiles/libshogun.dir/evaluation/CrossValidationPrintOutput.cpp.o] Error 1 make[1]: * [src/shogun/CMakeFiles/libshogun.dir/all] Error 2 make: * [all] Error 2 */

iglesias commented 10 years ago

Sure, @srgnuclear. If you remove includes from headers and those headers are relying on the includes to make use of classes or methods defined in those headers, then you are going to get compile errors.

What you should check is if the headers really need to have these includes. It can be, for instance, that the dependency comes from the implementation of a method in a header. Then, you can just move the implementation to the cpp file (this does not apply, at least in a straightforward way, for template classes). Another case is that a header is just making use of a class in a method signature (as the return value or argument). Then forward declaration in the header should be enough.

This is not an exhaustive explanation covering every case but I hope that it at least you gives a better picture of what's going on.

karlnapf commented 10 years ago

You have to do this one by one, not all of them at once. And then compile after each change.

srgnuclear commented 10 years ago

I went through each class one by one and compiled on making changes and results are i transfered non shogun includes from header files to .cpp for all classes succesfully in classifier except for ./classifier/mkl/MKLMulticlassOptimizationBase.h:#include < vector > which gave compilation error on transfering < vector > include to .cpp.

karlnapf commented 10 years ago

The error message should help you solve the problem. What is it exactly? Are there any vectors in the interfaces?

srgnuclear commented 10 years ago

Few errors like

/home/saurabh/shogun-install/shogun-3.1.1/src/shogun/../shogun/classifier/mkl/MKLMulticlassOptimizationBase.h:52:48: error: expected ‘,’ or ‘...’ before ‘<’ token virtual void addconstraint(const ::std::vector & normw2, ^ /home/saurabh/shogun-install/shogun-3.1.1/src/shogun/../shogun/classifier/mkl/MKLMulticlassOptimizationBase.h:60:35: error: ‘std::vector’ has not been declared virtual void computeweights(std::vector & weights2);

In file included from /home/saurabh/shogun-install/shogun-3.1.1/src/shogun/classifier/mkl/MKLMulticlassGradient.cpp:14:0: /home/saurabh/shogun-install/shogun-3.1.1/src/shogun/../shogun/classifier/mkl/MKLMulticlassGradient.h:66:35: error: ‘vector’ in namespace ‘std’ does not name a type virtual void addconstraint(const ::std::vector & normw2, ^ /home/saurabh/shogun-install/shogun-3.1.1/src/shogun/../shogun/classifier/mkl/MKLMulticlassGradient.h:66:42: error: ISO C++ forbids declaration of ‘parameter’ with no type [-fpermissive] virtual void addconstraint(const ::std::vector & normw2,

karlnapf commented 10 years ago

Try forward declaring vector

srgnuclear commented 9 years ago

changes in classifiers have been merged in - https://github.com/shogun-toolbox/shogun/pull/2646. Which class should i pick up next?

karlnapf commented 9 years ago

just grep for includes and change all classes in that folder

srgnuclear commented 9 years ago

i have changed all classes in classifier folder which folder should i be picking up next?

srgnuclear commented 9 years ago

I went on with transfer folder where in multitask several header files did not have corresponding .cpp files so for now i have checked only for those which had their .cpp files.

karlnapf commented 9 years ago

some of @lisitsyn s stuff is header only I think.... Sergey?

srgnuclear commented 9 years ago

all folders except lib and mathematics have been merged. Should i proceed with lib now??

karlnapf commented 9 years ago

yeah go for it :)

Ah wait, but lib is somehow different as there might be external libraries in there. Make sure to focus on those classes that are exposed via SWIG first

srgnuclear commented 9 years ago

All the files have been checked till #2660 and #2661 and previous merges. I have either removed unused includes or shifted non shogun includes to .cpp file(all those which could be done without generating any conflicts).

spandan1234 commented 8 years ago

i tried to compile the shogun file after building it using cmake. But I am encountering error. The details of compilation is as follows:

Edit by @karlnapf : @spandan1234 Sorry for editing your post, but this is both off-topic and please dont paste such long outputs in github threads. Just open a new one and post a gist link with the error message. And read on how to communicate on github, otherwise it is unlikely that you get help.