0

I successfully managed to compile bitcoind using the shipped configure script/makefile. Now I want to code something myself and added a folder inside the src directory. The problem now: how do I add my cpp files to the Makefile? When compiling, I get undefined references to functions I implemented inside my cpp files. When looking inside my folder, there are no .o files or anything similar, so I assume they are not compiled. I am completely novice to autoconf/automake and have no idea how to add something to those complicated makefile/configure scripts..

Best wishess to all of you

1

Bitcoin uses the autotools build system in order to build the source code. It is a very powerful, yet notoriously confusing system. You will need to edit the Makefile.am file to include the source files you want to build, and to point the linker to compiled sources. You will then need to rerun parts of the build system (automake, ./configure, etc...) in order to regenerate Makefile.

The specifics for how to do this are difficult to say, since you will need to determine which parts of the system your new code depends on, and which parts depend on your new code. I suggest reading up on autotools, determining what is needed for your particular code changes.

| improve this answer | |
  • Thank you very much for your answer, but I am still not able to add my file to Makefile.am. When taking a look at that file, I cannot find any place where a .c/.cpp file is mentioned. I also tried to rerun autoscan/autoconf/automake only getting worse and worse :( – GladHeAteHer Jun 13 '17 at 13:46
  • @GladHeAteHer, bitcoin is a complex project. The root Makefile.am will list subdirectories which contain their own Makefile.am files, which in turn point to other subdirectories with other Makefile.am files. It is in these files where you need to add your new files. As I said in the answer, the specifics are going to be determined by what you are changing and in which order it needs to compile. I highly recommend learning more on autotools before continuing. – Jestin Jun 13 '17 at 15:50
  • Thanks, I found another Makefile.am to which I could add my own .cpp files and it works now :) – GladHeAteHer Jun 16 '17 at 10:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.