Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>To answer the specific question, how to convert several source files into a single archive file for static linking; it is a two step operation. You must first compile the source files into object files, followed by turning the object files into an archive.</p> <p>If you have MSYS with your MinGW installation, I recommend using that. If not, you can still use Windows' command prompt cmd.exe.</p> <p>Make sure your MinGW/bin directory is part of the PATH environment variable so you can invoke the compiler from anywhere.</p> <p>From the command line, move into the directory that holds the source code. From there, type the command</p> <pre><code>mingw32-gcc -O2 -c [files] -I[header directory] </code></pre> <p>You should either name the <code>[files]</code> specifically, <code>-c a.cpp b.cpp c.cpp</code> or you can identify them all with <code>*.cpp</code>. <code>[header directory]</code> is where the .h files for the source are, relative to you. Generally, source files will be in a directory by themselves called /src, and header files in a sister directory called /include. You would refer to that directory as <code>-I../include</code>. If the header files are in a directory called /include within the /src directory, it would be <code>-Iinclude</code>.</p> <p>Once you have generated the .o files, you type the command</p> <pre><code>ar rcs lib[something].a [files] </code></pre> <p>Replace <code>[something]</code> with the name of the library. This is the name that will go in the Link Libraries dialog in Code::Blocks. Files is either the name of the object files you created before (a.o, b.o, c.o) or, if there are no unrelated object files in the directory, you can put in <code>*.o</code>.</p> <p>That should result in the archive file being created within the directory. You can now place it in the proper directory (possibly a sister directory to /include called /lib), and add that directory to your Code::Blocks configuration, under Linker Search Directories. You must then remember to actually add the library for you project.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload