Lib Pfad für makefile

Irischka79

Grünschnabel
Guten Tag,

weiß jemand wie man einen Library-pfad in einem makefile eingibt. Bei mir werden die Libs nicht gefunden und alle einzeln in Ordner reinschmeisen ist auch nicht das ware.

Danke
 
Hi.

Normalerweise fügt man die entsprechende Option in die LDFLAGS Variable ein:
Code:
LDFLAGS = -Lc:\foo\bar\

Wenn das nicht klappt mußt du mal etwas detaillierter werden. Du kannst das Makefile ja mal posten...
 
Hier ist ein Stückchen vom makefile:

Makefile for Independent JPEG Group's software

# This makefile is for Microsoft Visual C++ on Windows NT (and 95?).
# It builds the IJG library as a statically linkable library (.LIB),
# and builds the sample applications as console-mode apps.
# Thanks to Xingong Chang, Raymond Everly and others.

# Read installation instructions before saying "nmake" !!
# To build an optimized library without debug info, say "nmake nodebug=1".

# Pull in standard variable definitions
!include <win32.mak>

# You may want to adjust these compiler options:
CFLAGS= $(cflags) $(cdebug) $(cvars) -I.
# Generally, we recommend defining any configuration symbols in jconfig.h,
# NOT via -D switches here.

# Link-time options:
LDFLAGS= $(ldebug) $(conlflags)

# To link any special libraries, add the necessary commands here.
LDLIBS= $(conlibs)


# Put here the object file name for the correct system-dependent memory
# manager file. For NT we suggest jmemnobs.obj, which expects the OS to
# provide adequate virtual memory.
SYSDEPMEM= jmemnobs.obj

# miscellaneous OS-dependent stuff
# file deletion command
RM= del

# End of configurable options.

ich dachte mir, dass man bei LDLIBS was einfügen sollte? Es werden doch keine LIBS gefunden, warum dann unter LDFLAGS
 
Irischka79 hat gesagt.:
ich dachte mir, dass man bei LDLIBS was einfügen sollte? Es werden doch keine LIBS gefunden, warum dann unter LDFLAGS
Die Variable LDLIBS enthält eine Aufzählung der Bibliotheken die der Linker zum Programm hinzulinken soll. LDFLAGS enthält extra Flags (wie z.B. Pfade zu Bibliotheken) die dem Linker beim Aufruf übergeben werden.

Da du Visual C++ benutzt solltest du zur LDFLAGS Variable eine oder mehrere Option(en) wie z.B.
Code:
/LIBPATH:c:\mylibs

Alternativ könntest du auch die Pfade in der Umgebungsvariablen LIB durch Semikola gentrennt angeben.

Oder du kannst das natürlich auch in der grafischen Umgebung anpassen:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore/html/_core_linker_reference.asp hat gesagt.:
To set this linker option in the Visual Studio development environment

1. Open the project's Property Pages dialog box. For details, see Setting Visual C++ Project Properties.
2. Click the Linker folder.
3. Click the General property page.
4. Modify the Additional Library Directories property.
 
Danke schön,
ich hab es ausprobiert aber irgendwie funktioniert es nicht bekomme so ein Fehler auf der Konsole:
link -L"c:\programme\microsoft visual studio\vc98\lib" -out:cjpeg.exe cjpeg.obj rdppm.obj rdgif.obj rdtarga.obj
rdrle.obj rdbmp.obj rdswitch.obj cdjpeg.obj libjpeg.lib kernel32.lib ws2_32.lib mswsock.lib advapi32.lib
Microsoft (R) Incremental Linker Version 6.00.8168
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.

LINK : warning LNK4044: Nicht erkannte Option "Lc:\programme\microsoft visual studio\vc98\lib"; ignoriert
LINK : fatal error LNK1104: Datei "OLDNAMES.lib" kann nicht geoeffnet werden
NMAKE : fatal error U1077: 'link' : Rueckgabe-Code '0x450'
Stop.

und im makefile hab ich das eingegeben:

# You may want to adjust these compiler options:
CFLAGS= $(cflags) $(cdebug) $(cvars) -I. -I"C:\programme\microsoft visual studio\vc98\include"
# Generally, we recommend defining any configuration symbols in jconfig.h,
# NOT via -D switches here.

# Link-time options:
#LDFLAGS= $(ldebug) $(conlflags)
LDFLAGS= -L"c:\programme\microsoft visual studio\vc98\lib"

...warum funktioniert es mit includes und mit libs nicht? Ich kann nicht in der grafischer Oberflächen dass eingeben, mein Prof sagt es muss so eine exe ausspucken.
 
Die Option mit -L<pfad> war für andere Compiler gedacht (ich wußte da ja noch nicht welchen Compiler du verwendest, du hattest es nicht erwähnt). Bei Microsoft's C++ Compiler mußt du /LIBPATH:<pfad> benutzen.
 
Zurück