Chris
Chris

Reputation: 53

Linking libraries with minGW

I am using: Windows 7; MinGW (GCC) version 4.8.1; c++

I have several own build libraries which links together to an executable. A simple example with one library to link: libFolder\libforms.a

A) g++ -o main\theApp.exe main\main.o -LlibFolder\ -lforms

B) g++ -o main\theApp.exe main\main.o libFolder\libforms.a

Both generate the same executable.

Upvotes: 2

Views: 4962

Answers (1)

Some programmer dude
Some programmer dude

Reputation: 409432

The difference between the two commands is that in the first you add a path for the linker to search and you tell the linker to search for the forms library in the search paths, and in the second command you tell the linker to link directly with a specific library without needing to search for it.

Both commands works equally well, and will produce the same result. Which one you choose is totally up to you. The only drawback to the second variant is if you must link with multiple libraries, as then you must provide the same path multiple times, which you don't have to do with the first variant.

Upvotes: 2

Related Questions