Thread: Creating my own library

  1. #1
    Registered User
    Join Date
    Feb 2002
    Posts
    24

    Creating my own library

    Hello all

    In my project I need to create libraries out of a few of my modules.

    So I tried practicing library-making in the most basic way:
    (Im working with visual c++)

    1> I created a new project ->win 32 static library (lets call it test)
    2>I added one of my modules to it (lets call it Mod.c ) using the project->addtoProject->files

    3>I compiled and performed build via build->build test.lib

    4>I then added the path to test.lib (under the Debug library) in my main project (by going to project->settings->link panel->object/library Modules)


    When performing build to my main project, the following link error appears:
    LNKI2001 Unresolved External Symbol Winmain@16


    Please help me, and if possible, guide me step by step , as I've been trying very hard with no luck, and am becominbg desperate.


    Thanks a bunch!

    gozlan
    And if you get no joy from music hall
    Remember there is always alcohol
    And If you get no joy from Gin
    Here is the abyss jump in

  2. #2
    Banned Troll_King's Avatar
    Join Date
    Oct 2001
    Posts
    1,784
    Couldn't you just put all of the library declarations and prototypes into a header file than define the functions and variables in a source file. Lastly include the header file in your main file.

  3. #3
    Registered User
    Join Date
    Feb 2002
    Posts
    24
    no. I was specifically asked to create libraries out of each and every module.

    Working with Source and Header files is the way I usually work.

    I know I'm missing a small detail from the procedure of creating my own library and am hoping it would ring a bell to someone here.
    And if you get no joy from music hall
    Remember there is always alcohol
    And If you get no joy from Gin
    Here is the abyss jump in

  4. #4
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    Originally posted by Troll_King
    Couldn't you just put all of the library declarations and prototypes into a header file than define the functions and variables in a source file. Lastly include the header file in your main file.
    Do what Troll_King said. Instead of asking you if you can I'm going to tell you to do it. You are trying to make something harder than it actually is.

    [edit]
    Aside from the other advise I need a bit more information. Are you trying to compile your library and your executable at the same time? Also are you letting your compiler know that you are building a library and not an executable. Maybe that is your problem.
    [/edit]
    Last edited by master5001; 10-14-2002 at 03:58 PM.

  5. #5
    bobish
    Guest
    >>no. I was specifically asked to create libraries out of each and every module.

    this would imply that gozlan is doing this for work or as a homework assignment, meaning it has to be done that way.

  6. #6
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    Good point. The bad news is that I refuse to help people with stupid homework assignments. I have never had to do what he is doing EVER. But he should still check on what the compiler is doing. I have a feeling that compiler is not aware that it is not compiling an exe (hense the warning about missing main/WinMain) so he should start there. ....mumble, mumble... stupid, useless assignments...mumble

  7. #7
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    Perhaps you could add main to the compiled lib as an entry point. When I compile DLL's you have to include a special main function to handle the function calls. This makes sense since the linker must know where to start resolving external symbols/references....
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  8. #8
    Registered User
    Join Date
    Feb 2002
    Posts
    24
    well, you are al right of course, but yes- its stupid hoemwork,Worse than that, its a project Ive been working on for a few months, and I dont feel like becoming erbeliant near the end.

    I did find out that when creating my project as a win 32 console application, there is no problem, but when doing so in win32 application ( again, as I was asked)- then I have a problem.


    And yes, i am building it as lib, not as exe.


    Is there a different procedure for including in a win32 application (not console)?
    And if you get no joy from music hall
    Remember there is always alcohol
    And If you get no joy from Gin
    Here is the abyss jump in

  9. #9
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    Dunno, but you might try this (perhaps futile) idea...

    BOOL APIENTRY
    DllMain ( HINSTANCE, DWORD, LPVOID )
    {
    return 1;
    }


    or:


    int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
    {
    return 1;
    }
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Makefile for a library
    By sirmoreno in forum Linux Programming
    Replies: 5
    Last Post: 06-04-2006, 04:52 AM
  2. Replies: 19
    Last Post: 01-12-2006, 11:04 AM
  3. very weird .h problem
    By royuco77 in forum C++ Programming
    Replies: 1
    Last Post: 09-11-2005, 07:55 AM
  4. Replies: 4
    Last Post: 11-12-2002, 06:26 AM
  5. Creating extra library
    By Unregistered in forum C++ Programming
    Replies: 1
    Last Post: 03-28-2002, 06:48 PM