2

I want to achieve a basic functionality of an "in-file" encrypted file system, for that I am trying to use open-source truecrypt's files, I want to be able to instantiate the VolumeCreate class and call its functios, using just one algorithm, nothing sophisticated, I want to do this for educational purposes. I get the following errors:

> /tmp/cc92sV4t.o: In function `main':
a.cpp:(.text+0x31): undefined reference to `TrueCrypt::VolumeCreator::VolumeCreator()'
/tmp/cc92sV4t.o: In function `TrueCrypt::SharedVal<unsigned long>::Decrement()':
a.cpp:    (.text._ZN9TrueCrypt9SharedValImE9DecrementEv[TrueCrypt::SharedVal<unsigned                     long>::Decrement()]+0x18): undefined reference to `TrueCrypt::Mutex::Lock()'
a.cpp:(.text._ZN9TrueCrypt9SharedValImE9DecrementEv[TrueCrypt::SharedVal<unsigned         long>::Decrement()]+0x48): undefined reference to `TrueCrypt::Mutex::Unlock()'

collect2: ld returned 1 exit status

for the following code:

#include "Core/VolumeCreator.h"

using namespace TrueCrypt;
int main(int argc, char **argv)
{
    VolumeCreator *vct = new VolumeCreator();
    struct VolumeCreationOptions opt;
    return 0;
}
rsk82
  • 28,217
  • 50
  • 150
  • 240
AlexandruC
  • 3,527
  • 6
  • 51
  • 80
  • 1
    You'll need to link to the implementation of `VolumeCreator`. – David Schwartz May 19 '12 at 10:53
  • 1
    One way would be to add the implementation files to your project. Another way would be to compile the implementation into a library and add that library file to your project. – David Schwartz May 19 '12 at 11:15
  • The implementation files (.cpp) are in place, same directory as the headers, if I add for example #include "VolumeCreator.cpp" to my project other undefined references errors will be shown, but isn't it enough to just include the header file? I'm taking in consideration the library option. – AlexandruC May 19 '12 at 11:31
  • 2
    Including the header file is enough to make that file compile. But to make the program link, you have to add to the project the actual implementations of the classes you are using. (Either by adding the .cpp files or by linking to a library.) Simplest solution: Keep adding the necessary .cpp files until the undefined references all go away. – David Schwartz May 19 '12 at 11:33
  • Hi Alexcalin, you don't need sentences like "Anyone? Please. Thanks" in your question. It's even discouraged for stackoverflow. Note that this is basically a starter question for C/C++ development - beware that encryption API's are not the most easy to handle most of the time (but don't let that put you off). – Maarten Bodewes May 19 '12 at 16:20
  • Thank you for advice and edit, I'm also a starter here, as with c++ (just plain uni level). And boy you are right about these encryption API's, but I have to build a file-hosted encrypted filesystem ,I don't need all the optimization and filesystem types or most of those stuff in truecrypt. Any quick tricks with this? I'm in a real shortage of time. – AlexandruC May 19 '12 at 18:38
  • This is programming, there are no quick tricks unfortunately. Starting off with encryption is the hard knock life for programmers, I can only mod up your questions and answer questions about crypto... – Maarten Bodewes May 20 '12 at 01:40
  • Thanks. I'll be going down the rabbit hole then. – AlexandruC May 20 '12 at 10:53

0 Answers0