Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

linking problem with a foreign library

Status
Not open for further replies.

satellite03

IS-IT--Management
Dec 26, 2003
248
IN
hi,

i have downloaded a library from

to make it work i read the readme file of the library.

there it is written to get exe
i have to do like below...


========================
Microsoft Visual C++ 6.0
========================
run : mkallmsc.bat (builds library + 4 executables)


so
i simply clicked on mkallmsc.bat.... a DOS window came and blinked away quickly.

then i
tried to write a small code.....the library has suggested to write #include "m_apm.h" at the begining of the code...

i did that ..
but at the compilation time it is saying :

fatal error C1083: Cannot open include file: 'm_apm.h': No such file or directory
Error

and surprisingly the demo code given in the library itself is giving the same kind of error.

why it is not able to find the library??

my program path is c:\pg\abc.cpp
and my library is in C:and path of 'm_apm.h' is C:\mapm\mapm_4.9

can you tell me why this library is not linking? how can i fix it?

any suggestion ?
 
add additional include path to downloaded library with .h files and additional library path to files what contains .lib or .obj files.

Ion Filipski
1c.bmp
 
hi ion,

>>>"add additional include path to downloaded library with .h files and additional library path to files what contains .lib or .obj files"

probabily what you are saying i did that....but still its not working.

i have posted this question to C forum earlier...but no successes


 
Great,
>fatal error C1083: Cannot open include file: 'm_apm.h':...
it is compile(not link) error only because of
1. path to m_apm.h is not specified in compiller options
for additional include paths
or
2. m_apm.h is missing.

So, correct 1 and 2. If you did eevrithing correctly you will get different error than that or you will not get any errors.

Ion Filipski
1c.bmp
 

hi Ion,

ok, let me tell you clearly

my library folder

is C:\mapm\mapm_4.9 .. here there are more than 30 files(.c extension), 2 files(.h extension e.g m_apm.h and m_apm_lc.h) and 2 folder (e.g name: multithread(it has two .h extesion file inside) and dost_nt_9x(batch files for various compilers) .....ok

so your option 2 is not applicable bcoz m_apm.h is there.

about option 1 ...i could not understand that.

what i did i am telling you,

i simply went to setting(ALT-F7)>TAB C/C++ > catagory-preprocessor>"additional include directories" > i typed here C:\mapm\mapm_4.9......thats it.

and nothing else i did...then i opened a demo code and tried to execute...and got the error message again.

NOW,your comment " path to m_apm.h is not specified in compiller options for additional include paths "

what i did i told you clearly....do you feel i need to do something more? then what is that?

one more thing there is no caption like "additional include path" but "additional include directories" is there....i beleive you mean the same thing.

what should i do now? its VC++ 6.0
if you give steps then it would be very much helpful.

thanks




 

hi Ion ...i am also sending responses in C forum also.

if you keep track that.....then you will understand my problem.

it would have been good if the threads are been merged.

anyway, i am keping track both the responses.

thanks
 
is your .cpp file you try to compile a part of the project where you have just set the include paths? If no, the you should create a project, include the .cpp in your project. To include it in your project means to copy it in the directory of project. Then from your project you should explicitly add it to project. Look again in setting of your project if the path is included.

Anyway, you did the right steps, but you have commited an error on doing that. No other things in this direction you may do. Only find what you did wrong and correct it.

Ion Filipski
1c.bmp
 
ok...

just now i checked again...but unsuccesfull

as you are saying so,


i first created a project by doing below

file>new>win32 console application > ok>finish

then project>add to project >new file>c/c++ source file>ok

so now in my project pro // this name i have given
i have only new.cpp source file // this name i have given


now i am setting path as earlier by typing in "additional include directories" c:\mapm\mapm4.9......ok

To be sure i have checked the file-view in the workspace.

i found there information like this
project name : pro
source name :new.cpp
external dependencies :m_apm.h
....
....

in new.cpp i just typed a demo code(pi2.cpp) of the library

.... but still at the exe time its giving error

errors are :



Configuration: pro - Win32 Debug--------------------
Linking...
new.obj : error LNK2001: unresolved external symbol _m_apm_cpp_precision
new.obj : error LNK2001: unresolved external symbol _m_apm_init
new.obj : error LNK2001: unresolved external symbol _m_apm_set_string
new.obj : error LNK2001: unresolved external symbol _m_apm_copy
new.obj : error LNK2001: unresolved external symbol _m_apm_free
new.obj : error LNK2001: unresolved external symbol _m_apm_set_long
new.obj : error LNK2001: unresolved external symbol _m_apm_to_string
new.obj : error LNK2001: unresolved external symbol _m_apm_compare
new.obj : error LNK2001: unresolved external symbol _m_apm_add
new.obj : error LNK2001: unresolved external symbol _m_apm_subtract
new.obj : error LNK2001: unresolved external symbol _m_apm_multiply
new.obj : error LNK2001: unresolved external symbol _m_apm_significant_digits
new.obj : error LNK2001: unresolved external symbol _MM_cpp_min_precision
new.obj : error LNK2001: unresolved external symbol _m_apm_divide
new.obj : error LNK2001: unresolved external symbol _m_apm_exponent
new.obj : error LNK2001: unresolved external symbol _m_apm_round
new.obj : error LNK2001: unresolved external symbol _m_apm_sqrt
Debug/pro.exe : fatal error LNK1120: 17 unresolved externals
Error executing link.exe.

pro.exe - 18 error(s), 0 warning(s)


what happened to this library?
















 
Those linker errors are probably due to you not specifying the library to use. You can either add the library that comes with the header to your librarys in your project options or alternatively look up #pragma comment in your help files for specifying the library that way.Remember a header file is usually not a library but only a description of what is available in the library.
 
Great, unresolved externall.... already is another kind of error. As I can see now the first problem about "can't find....." is solved. Isn't it?
The linker errors about unreslved externals you should solve by adding the compilled .lib with imlemented functionality to your projects linker additional deppendenties. So, as I see everything was compilled ok, of code begun to link. So, now resolve problem with linker path and linker dependencies in quite the same way. Only difference is what you should add the lib names explicitly in your settings.

Ion Filipski
1c.bmp
 
hi, Ion

your comment

"Only difference is what you should add the lib names explicitly in your settings "

but how ?? do you mean i should go to Link tab in the setting option?

well, i went there also, and i found in the object/library modules dialouge following things

kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib

hmmmm....my foreign library is not here!!! i see.

may be library has not been built up..i am not sure.

can you plz have a look in C forum link, where i have tried to build the library again. the link is :

Code:
thread205-771578


thanks

 
It means your additional library have some source code (.c and/or .cpp files) what should be compilled and linked. If after compilling your library are not resulted any .lib then you should add resulted .obj files to linker dependencies. If not, then you should comille your project with source files (.c and .cpp) of your library.

Ion Filipski
1c.bmp
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top