1,105,380 Community Members

Using an external library in a program

Member Avatar
ben1996123
Junior Poster in Training
87 posts since May 2011
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

Hello, I just downloaded the big integer library, and I want to use it in my prime number checking program. I downloaded the zip file and got a bunch of .cc and .hh files. I need to know what to do with the files, where I should put them, and what code to type to get C++ to actually use it.

I want numbers greater than 2.14*10^9 D:

Thanks.

PS. If it matters, the IDE I am using is Code::Blocks.

Member Avatar
thines01
Postaholic
2,420 posts since Oct 2009
Reputation Points: 389 [?]
Q&As Helped to Solve: 413 [?]
Skill Endorsements: 10 [?]
Team Colleague
Featured
 
0
 

If you are using Visual Studio, create a project name BigInt as a .lib project. Extract the files from the BigInt archive to the directory created by the project.

Drag/drop (or just add) the .cc files to the source folder and the .hh files to the header folder.

Eliminate the testsuite.cc and sample.cc
Complile the app.
Now, it's a library you can use.

Add an additional project to the workspace as an EXE project.
Make the BigInt project a dependency.
#include the full path of the BigInteger.hh file
Compile.

There are multiple samples in the sample.cc file.


If you re using a command-line compiler, see the makefile that is included with the archive.

Member Avatar
ben1996123
Junior Poster in Training
87 posts since May 2011
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

If you are using Visual Studio, create a project name BigInt as a .lib project. Extract the files from the BigInt archive to the directory created by the project.

Drag/drop (or just add) the .cc files to the source folder and the .hh files to the header folder.

Eliminate the testsuite.cc and sample.cc
Complile the app.
Now, it's a library you can use.

Add an additional project to the workspace as an EXE project.
Make the BigInt project a dependency.
#include the full path of the BigInteger.hh file
Compile.

There are multiple samples in the sample.cc file.


If you re using a command-line compiler, see the makefile that is included with the archive.

I'm using codeblocks.

Member Avatar
ben1996123
Junior Poster in Training
87 posts since May 2011
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

Bump.

Member Avatar
ravenous
Practically a Master Poster
682 posts since Jul 2005
Reputation Points: 251 [?]
Q&As Helped to Solve: 112 [?]
Skill Endorsements: 13 [?]
 
0
 

If you've downloaded a bunch of .cc and .h files then you have the source files for the library. In this case, the easiest thing to do is to copy the files into a directory in the directory where you have the source for your project and then simply add them to the project in Code::Blocks. You do this by right-clicking on your project (in the left pane) and then choose "add files recursively..." from the context menu. Choose the directory that you put the files from the Big Integer Library in and then hit OK. This should add all the files to your project. Then you just need to #include the header files that you need in your own cpp/h files. So, if you had the library files in a directory called "BIL" then you'd do:

#include "BIL/BigInteger.hh"

Hope that helps :o)

Member Avatar
ben1996123
Junior Poster in Training
87 posts since May 2011
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

If you've downloaded a bunch of .cc and .h files then you have the source files for the library. In this case, the easiest thing to do is to copy the files into a directory in the directory where you have the source for your project and then simply add them to the project in Code::Blocks. You do this by right-clicking on your project (in the left pane) and then choose "add files recursively..." from the context menu. Choose the directory that you put the files from the Big Integer Library in and then hit OK. This should add all the files to your project. Then you just need to #include the header files that you need in your own cpp/h files. So, if you had the library files in a directory called "BIL" then you'd do:

#include "BIL/BigInteger.hh"

Hope that helps :o)

Thanks :D

Question Answered as of 2 Years Ago by ravenous and thines01
You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: