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.

Dani AI

Generated

Two practical ways to use the Big Integer source in Code::Blocks are offered below — one fast and simple, the other a cleaner reuse-friendly approach. Both avoid changing the library code and keep the project build deterministic.

Place the library sources inside the project tree and add them to the project. Put the .hh headers in a small "include" subfolder and the .cc files in a "src" subfolder inside the project workspace. Add the include folder to the compiler search path (Project → Build options → Search directories → Compiler). Exclude any test/sample files (those contain their own main and will cause duplicate-main or link errors). This is the easiest route and follows the gist of ’s suggestion.

Build the library once and link it from the application for a cleaner setup. Create a Static Library project in the same workspace, add the library .cc files (omit tests), build to produce the archive (.a/.lib). Then in the application project add the library file under Linker settings and add the library’s include folder to the compiler search path. Make the app depend on the library project so Code::Blocks builds it first. This mirrors the idea described but keeps build/config steps explicit.

Common pitfalls and quick fixes:

  • "Header not found": add the header folder to Project → Build options → Search directories → Compiler.
  • "Multiple definition of main": remove or exclude tests/sample files.
  • "Undefined references": confirm the library objects or archive are actually being linked and that both projects use the same compiler/ABI, bitness and debug/release settings.
  • For primality on large numbers, use a probabilistic test (Miller–Rabin) implemented with repeated modular exponentiation using the big-integer operations provided by the library.

Credit to and — their answers point to the two standard workflows above; this note adds the Code::Blocks menu locations and troubleshooting cues that are often the missing bits.

Recommended Answers

All 5 Replies

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 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 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.

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 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 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.

Bump.

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)

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.