srcML / nameCollector

Finds all the user defined identifier names in source code file(s). Works for C, C++, C#, and Java files.
http://www.srcML.org
GNU General Public License v3.0
2 stars 0 forks source link

Lack of srcml-config.cmake #1

Closed haruki3hhh closed 6 months ago

haruki3hhh commented 6 months ago

I have compiled the srcML in /root/srcML, and want to compile nameCollector in /root/nameCollector but output errors as following:

root@18ec7fd7e01b:~/nameCollector# srcML_DIR=/root/srcML/ cmake 
Usage

  cmake [options] <path-to-source>
  cmake [options] <path-to-existing-build>
  cmake [options] -S <path-to-source> -B <path-to-build>

Specify a source directory to (re-)generate a build system for it in the
current working directory.  Specify an existing build directory to
re-generate its build system.

Run 'cmake --help' for more information.

root@18ec7fd7e01b:~/nameCollector# srcML_DIR=/root/srcML/ cmake .
CMake Error at CMakeLists.txt:44 (find_package):
  By not providing "FindsrcML.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "srcML", but
  CMake did not find one.

  Could not find a package configuration file provided by "srcML" with any of
  the following names:

    srcMLConfig.cmake
    srcml-config.cmake

  Add the installation prefix of "srcML" to CMAKE_PREFIX_PATH or set
  "srcML_DIR" to a directory containing one of the above files.  If "srcML"
  provides a separate development package or SDK, be sure it has been
  installed.

-- Configuring incomplete, errors occurred!
See also "/root/nameCollector/CMakeFiles/CMakeOutput.log".
mlcollard commented 6 months ago

Please remove the command entry mistake above and focus on the error.

mlcollard commented 6 months ago

Was srcML installed from the develop branch? Do that, or request an installer.

Also, it appears above that the cmake is being run to build in the source directory. In cmake, prefer out-of-source builds, not in-source builds.

haruki3hhh commented 6 months ago

Thank you for comments!

I checkout to origin/develop and recompile the srcML with cmake 3.28 as following:

cmake .
make -j

and recompile the nameCollector by:

cmake . -DsrcML_DIR=~/srcML/ 

The error msg goes to:

root@b9aa49420b57:~/nameCollector# cmake . -DsrcML_DIR=~/srcML/ 
CMake Error at CMakeLists.txt:44 (find_package):
  Found package configuration file:

    /root/srcML/srcMLConfig.cmake

  but it set srcML_FOUND to FALSE so package "srcML" is considered to be NOT
  FOUND.  Reason given by package:

  LibsrcML `shared` libraries were requested but not found.

I checked the srcML/bin/ as following files there:

libsrcml.a  libsrcml.so  libsrcml.so.1  libsrcml.so.1.0.0  srcml
mlcollard commented 6 months ago

Don't build in the source directory. Build in a build directory.

mlcollard commented 6 months ago

Install using srcml from the develop branch. Do not set an environment variable, just install.

mlcollard commented 6 months ago

Again, for srcML, do not build in the source directory

haruki3hhh commented 6 months ago

Thank you for reminding me!

I changed my compiling way to:

cd srcML/
mkdir build
cmake ./CMakeLists.txt -B build
make -j`nproc` -C build/

And another error comes out as following:

[ 63%] Linking CXX shared library ../../bin/libsrcml.so
/usr/bin/ld: CMakeFiles/libsrcml.dir/qli_extensions.cpp.o: relocation R_X86_64_TPOFF32 against `__tls_guard' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: failed to set dynamic section sizes: bad value
collect2: error: ld returned 1 exit status
make[2]: *** [src/libsrcml/CMakeFiles/libsrcml_shared.dir/build.make:199: bin/libsrcml.so.1.0.0] Error 1
make[1]: *** [CMakeFiles/Makefile2:424: src/libsrcml/CMakeFiles/libsrcml_shared.dir/all] Error 2
make: *** [Makefile:166: all] Error 2

should I add a -fPIC flags to continue the compiling process?

Not sure if it will affect the nameCollector

mlcollard commented 6 months ago

Use the cmake presets. —preset macos-release or —preset ubuntu-release

On Mar 2, 2024, at 12:07 PM, haruki3hhh @.***> wrote:

CAUTION: This email originated from outside of The University of Akron. Use caution when opening attachments, clicking links or responding to requests for information.

Thank you for reminding me!

I changed my compiling way to:

cd srcML/ mkdir build cmake ./CMakeLists.txt -B build make -jnproc -C build/

And another error comes out as following:

[ 63%] Linking CXX shared library ../../bin/libsrcml.so /usr/bin/ld: CMakeFiles/libsrcml.dir/qli_extensions.cpp.o: relocation R_X86_64_TPOFF32 against `__tls_guard' can not be used when making a shared object; recompile with -fPIC /usr/bin/ld: failed to set dynamic section sizes: bad value collect2: error: ld returned 1 exit status make[2]: [src/libsrcml/CMakeFiles/libsrcml_shared.dir/build.make:199: bin/libsrcml.so.1.0.0] Error 1 make[1]: [CMakeFiles/Makefile2:424: src/libsrcml/CMakeFiles/libsrcml_shared.dir/all] Error 2 make: *** [Makefile:166: all] Error 2

should I add a -fPIC flags to continue the compiling process?

Not sure if it will affect the nameCollector

— Reply to this email directly, view it on GitHubhttps://github.com/srcML/nameCollector/issues/1#issuecomment-1974853746, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ABGLMV5YM2TD72Y2SUUAFBLYWIBOZAVCNFSM6AAAAABECQ6XVKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNZUHA2TGNZUGY. You are receiving this because you commented.Message ID: @.***>

haruki3hhh commented 6 months ago

Thank you for suggestion!

I do the following things:

cd ~/srcML/build
cmake .. --preset ubuntu-release
ninja
ninja install

and set the srcML_DIR path in nameCollector:

cd ~/nameCollector/build
cmake .. -DsrcML_DIR=~/srcML/build/

it seems still have some issues as following:

CMake Error at CMakeLists.txt:44 (find_package):
  Found package configuration file:

    /root/srcML/build/srcMLConfig.cmake

  but it set srcML_FOUND to FALSE so package "srcML" is considered to be NOT
  FOUND.  Reason given by package:

  LibsrcML `shared` libraries were requested but not found.
mlcollard commented 6 months ago

Quit setting the path. Do not set the path. Forget about srcML_DIR

Where is the result of the install?

On Mar 2, 2024, at 12:48 PM, haruki3hhh @.***> wrote:

CAUTION: This email originated from outside of The University of Akron. Use caution when opening attachments, clicking links or responding to requests for information.

Thank you for suggestion!

I do the following things:

cd ~/srcML/build cmake .. --preset ubuntu-release ninja ninja install

and set the srcML_DIR path in nameCollector:

cd ~/nameCollector/build cmake .. -DsrcML_DIR=~/srcML/build/

it seems still have some issues as following:

CMake Error at CMakeLists.txt:44 (find_package): Found package configuration file:

/root/srcML/build/srcMLConfig.cmake

but it set srcML_FOUND to FALSE so package "srcML" is considered to be NOT FOUND. Reason given by package:

LibsrcML shared libraries were requested but not found.

— Reply to this email directly, view it on GitHubhttps://github.com/srcML/nameCollector/issues/1#issuecomment-1974863173, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ABGLMV2KVOUDCCRDGVHRMO3YWIGGZAVCNFSM6AAAAABECQ6XVKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNZUHA3DGMJXGM. You are receiving this because you commented.Message ID: @.***>

haruki3hhh commented 6 months ago

Hi mlcollard,

I successfully compiled the nameCollector by not setting the srcML path!

Thank you very much for your patience : )

haruki3hhh commented 6 months ago

My Final build script:

git clone https://github.com/srcML/srcSAX.git
git clone https://github.com/srcML/srcML.git
git clone https://github.com/srcML/nameCollector.git

# first build srcML
pushd srcML
git reset --hard origin/develop
mkdir build
cmake . --preset ubuntu-release -B build/
ninja -C build/
ninja -C build/ install
popd

pushd srcSAX
mkdir build
cmake . -B build/
make -j`nproc` -C build/
make -C build/ install
popd

pushd nameCollector
mkdir build
cmake . -B build/
make -j`nproc` -C build/
file build/bin/nameCollector
popd