Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linking problem with redisserversample #244

Closed
marcosszydlo opened this issue Aug 1, 2018 · 5 comments
Closed

Linking problem with redisserversample #244

marcosszydlo opened this issue Aug 1, 2018 · 5 comments

Comments

@marcosszydlo
Copy link
Contributor

I would like to try out libjson-rpc-cpp. I am using Red Hat 7, so I pulled the project from github and I am following the instructions to build it. Everything compiles, but I am running into the following link error:

[ 66%] Linking CXX executable ../../bin/redisserversample
../../lib/libjsonrpccpp-server.so.1.0.0: undefined reference to pthread_create' ../../lib/libjsonrpccpp-server.so.1.0.0: undefined reference to pthread_join'
collect2: error: ld returned 1 exit status
make[2]: *** [bin/redisserversample] Error 1
make[1]: *** [src/examples/CMakeFiles/redisserversample.dir/all] Error 2
make: *** [all] Error 2

Do you have any suggestions as to how to proceed?

Thanks,
Marcos

@marcosszydlo
Copy link
Contributor Author

I was able to solve the problem by adding -pthread at the end of the command line in redisserversample.dir/link.txt. I ran into a similar problem again and fixed it for filedescriptorserversample.dir/link.txt the same way. But these files are built by cmake. Shouldn't the generated files already include the -pthread option?

The next error I am encountering is:
[ 93%] Building CXX object src/test/CMakeFiles/unit_testsuite.dir/test_integration.cpp.o
/afs/mitll/usr/MA28351/repos/libjson-rpc-cpp/src/test/test_integration.cpp: In function \u2018void ____C_A_T_C_H____T_E_S_T____0()\u2019:
/afs/mitll/usr/MA28351/repos/libjson-rpc-cpp/src/test/test_integration.cpp:143:13: error: \u2018pipe\u2019 was not declared in this scope
pipe(c2sfd);
^
/afs/mitll/usr/MA28351/repos/libjson-rpc-cpp/src/test/test_integration.cpp:166:17: error: \u2018close\u2019 was not declared in this scope
close(c2sfd[0]);
^
make[2]: *** [src/test/CMakeFiles/unit_testsuite.dir/test_integration.cpp.o] Error 1
make[1]: *** [src/test/CMakeFiles/unit_testsuite.dir/all] Error 2
make: *** [all] Error 2

Any suggestions?

@marcosszydlo
Copy link
Contributor Author

marcosszydlo commented Aug 3, 2018

I was able to close all my issues. It appears the latest code has not been built tested on Linux:

  • Several of the generated link.txt files are missing the flag "-pthread"
  • the test_integration.cpp file was missing #include <unistd.h>. Without that include the Linux calls pipe() and close() could not be resolved

After solving all these issues the whole code builds.

I'll be happy to submit the change to test_integration.cpp. I don't know enough of CMake to know where to change the generating files that build the link.txt files that are missing the pthread flag.

In any case, I'll now go and play with the code.

Thanks,
Marcos

@cinemast
Copy link
Owner

cinemast commented Aug 4, 2018

Could you prepare a PullRequest for that?

@marcosszydlo
Copy link
Contributor Author

I was able to figure out the problem with CMake. The following line was missing in CMakeDependencies.cmake:

find_package(Threads REQUIRED)

Now, the whole package builds in RedHat REL 7 (which is what I'm using).
I could prepare a PullRequest for all these issues, but have some questions:
Do I need to create a fork before issuing the PullRequest? Or can I just create a new branch and use the shared model?

Thanks,
Marcos

marcosszydlo pushed a commit to marcosszydlo/libjson-rpc-cpp that referenced this issue Aug 21, 2018
There are no code changes made. Three files were changed:
CMakeDependencies.cmake was missing the command

find_package(Threads REQUIRED)

The test file test_integration.cpp was missing an include file: <unistd.h>

The third file that I modified, CMakeLists.txt, should be restored to its
original form. I changed it so I could build withou HTTP, which I don't need.

The code was built and tested on RedHat REL 7 (with HTTP disabled in CMake).
cinemast pushed a commit that referenced this issue Aug 23, 2018
* Fixes to issue #244: libjson-rpc-cpp does not build on Linux.
There are no code changes made. Three files were changed:
CMakeDependencies.cmake was missing the command

find_package(Threads REQUIRED)

The test file test_integration.cpp was missing an include file: <unistd.h>

The third file that I modified, CMakeLists.txt, should be restored to its
original form. I changed it so I could build withou HTTP, which I don't need.

The code was built and tested on RedHat REL 7 (with HTTP disabled in CMake).

* Re-enable HTTP libs
@cinemast
Copy link
Owner

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants