This discussion is archived
8 Replies Latest reply: Mar 20, 2012 10:49 AM by gdarling - oracle RSS

error LNK2028: unresolved token (0A00001F) "public: static class oracle....

528977 Newbie
Currently Being Moderated
Hello,

I am using MSVC C++ Express and Oracle XE. When I am building my C++ script I get the following errors:

DbCheck.obj : error LNK2028: unresolved token (0A00001F) "public: static class oracle::occi::Environment * __clrcall oracle::occi::Environment::createEnvironment(enum oracle::occi::Environment::Mode,void *,void * (__clrcall*)(void *,unsigned int),void * (__clrcall*)(void *,void *,unsigned int),void (__clrcall*)(void *,void *))" (?createEnvironment@Environment@occi@oracle@@$$FSMPAV123@W4Mode@123@PAXP6MPAX1I@ZP6MPAX11I@ZP6MX11@Z@Z) referenced in function "int __clrcall main(cli::array<class System::String ^ >^)" (?main@@$$HYMHP$01AP$AAVString@System@@@Z)
DbCheck.obj : error LNK2019: unresolved external symbol "public: static class oracle::occi::Environment * __clrcall oracle::occi::Environment::createEnvironment(enum oracle::occi::Environment::Mode,void *,void * (__clrcall*)(void *,unsigned int),void * (__clrcall*)(void *,void *,unsigned int),void (__clrcall*)(void *,void *))" (?createEnvironment@Environment@occi@oracle@@$$FSMPAV123@W4Mode@123@PAXP6MPAX1I@ZP6MPAX11I@ZP6MX11@Z@Z) referenced in function "int __clrcall main(cli::array<class System::String ^ >^)" (?main@@$$HYMHP$01AP$AAVString@System@@@Z)
F:\Visual C++ Projects\DbCheck\Debug\DbCheck.exe : fatal error LNK1120: 2 unresolved externals

I downloaded OCCI for Visual C++ 8 (Windows) Download (zip). but still get the error. I also linked oraocci10.lib and oraocci10d.lib but still nogo. I did it in the project property page under linker->input->additional dependencies. The configuration I choosed was:

Configuration: Debug
Platform: Win32

Is there a way to determine what is missing or what is causing the error, does one of you know how to solve the problem?

Thanks

Rodger
  • 1. Re: error LNK2028: unresolved token (0A00001F) "public: static class oracle....
    526769 Newbie
    Currently Being Moderated
    What I usually do is just create a new filter (a group), and just add the lib files in there (Right click and select add existing item.., just type *.* in the filename part of the dialog after you have selected the folder that the libraries are in, then select both the debug and the release library). You might get a warning that Visual Studio does not understand how to build these files, just ignore that.

    Then select release build, right click on the oraocci10d.lib, select Properties and make sure you set excluded from Build to Yes.

    For debug build it is the opposite, select oraocci10.lib, select Proeprties and make sure you set excluded from Build to Yes.

    This works fine for me, I run VC++2005 8.0.50727-4200.

    Regards
  • 2. Re: error LNK2028: unresolved token (0A00001F) "public: static class oracle....
    528977 Newbie
    Currently Being Moderated
    Thanks for you help. But there is something strange:

    What I am trying to build is a Windows Forms Application what still a NOGO but when I am trying to build a Windows Console Application (what I do not really want) it goes OK except when using the oraocci10d.lib (is says it cannot find the file ??)

    Is there an explanation for this?
  • 3. Re: error LNK2028: unresolved token (0A00001F) "public: static class oracle....
    526769 Newbie
    Currently Being Moderated
    Could you post a bit of the code where you try to call for instance oracle::occi::createEnvironment. I'm just guessing here, but looking at the __clrcall in the unresolved tokens it might seem that it has wrongly assumed that you are calling managed code.
  • 4. Re: error LNK2028: unresolved token (0A00001F) "public: static class oracle....
    528977 Newbie
    Currently Being Moderated
    Here is the code:

    // DbCheck.cpp : main project file.

    #include "stdafx.h"
    #include "Form1.h"

    #include <iostream>
    #include <fstream>
    #include <string>
    #include <stdlib.h>
    #include <occi.h>

    using namespace oracle::occi;
    using namespace std;
    using namespace DbCheck;


    const string userName = "HR";
    const string password = "HR";
    const string connectString = "XE";     

    oracle::occi::Environment *env = oracle::occi::Environment::createEnvironment();

    [STAThreadAttribute]
    int main(array<System::String ^> ^args)
    {
         //ofstream OpenFile;
         //OpenFile.open("f:\\help\\DbCheck.txt");
         //OpenFile.close();

         Connection *conn = env->createConnection(
    userName, password, connectString);

         
         env->terminateConnection(conn);

         oracle::occi::Environment::terminateEnvironment(env);

         // Enabling Windows XP visual effects before any controls are created
         Application::EnableVisualStyles();
         Application::SetCompatibleTextRenderingDefault(false);

         // Create the main window and run it
         Application::Run(gcnew Form1());
         return 0;
    }

    Thanks..
  • 5. Re: error LNK2028: unresolved token (0A00001F) "public: static class oracle....
    526769 Newbie
    Currently Being Moderated
    Could you try to create a CLR command line application and get that to run first ?

    This example here links and runs fine for me (it is a bit messy since I've been experimenting with my own mem leak problems, but it runs fine, you might want to change the select statement though)

    (The stdafx.h file only contains #pragma once, the TestRead class is there just to test mapping from std::string to System::String)

    #include "stdafx.h"

    #include <occi.h>

    using namespace System;
    using namespace std;
    using namespace oracle::occi;

    public ref class TestRead
    {
    public:
         System::String^ GetStr(int index);
    internal:
         oracle::occi::ResultSet* m_resultSet;
    };

    System::String^ TestRead::GetStr(int index)
    {
         try
         {
              return gcnew System::String(m_resultSet->getString(index).c_str());
         }
         catch (const oracle::occi::SQLException& ex)
         {
              throw gcnew System::Exception(gcnew System::String(ex.getMessage().c_str()));
         }

         return "";
    }

    int main(array<System::String ^> ^args)
    {
    try
    {
         oracle::occi::Environment *env = oracle::occi::Environment::createEnvironment((oracle::occi::Environment::Mode)(oracle::occi::Environment::OBJECT | oracle::occi::Environment::THREADED_MUTEXED));
    Connection *conn = env->createConnection("test","test","");

    try
    {
    oracle::occi::Statement *stmt = conn->createStatement("Select site_addr From parcel");
    oracle::occi::ResultSet *rs = stmt->executeQuery();

         TestRead^ testread = gcnew TestRead();
         testread->m_resultSet = rs;

    //int MktId;
    string MktName;
    int rowno = 1;
    while (rs->next())
    {
              System::String^ name = testread->GetStr(1);
    rowno++;

         // if (rowno > 100)
         //     break;
    }

    stmt->closeResultSet(rs);
    conn->terminateStatement(stmt);
    }
    catch (SQLException &ex)
    {
    env->terminateConnection(conn);
    oracle::occi::Environment::terminateEnvironment(env);
    throw;//re-throw
    }
    env->terminateConnection(conn);
    oracle::occi::Environment::terminateEnvironment(env);
    }
    catch (SQLException &ex)
    {
    }


    Console::WriteLine(L"Hello World");
    return 0;
    }
  • 6. Re: error LNK2028: unresolved token (0A00001F) "public: static class oracle....
    528977 Newbie
    Currently Being Moderated
    Building a CLR goes ok. No problems at all..
  • 7. Re: error LNK2028: unresolved token (0A00001F) "public: static class oracle....
    528977 Newbie
    Currently Being Moderated
    I finaly solved the problem (after many hours :-) )

    I did the following:

    Step 1:

    Project->Add->New Filter->Existing Item = C:\oraclexe\app\oracle\product\10.2.0\server\OCI\lib\MSVC\vc8\oraocci10.lib
    Project->Add->New Filter->Existing Item = C:\oraclexe\app\oracle\product\10.2.0\server\OCI\lib\MSVC\vc8\oraocci10d.lib

    One of the above must have the setting : Excluded from build YES/NO depending if the configuration is "Debug" or "Release"

    Step 1a (I don't know if this is necessary but it works without)
    Project->Add->New Filter->Existing Item = C:\Program Files\Microsoft Visual Studio 8\VC\lib\MSVCPRT.lib
    Project->Add->New Filter->Existing Item = C:\Program Files\Microsoft Visual Studio 8\VC\lib\MSVCRT.lib


    Step 2:
    Project->Properties->Configuration Properties->C/C++->Processor Definitions = WIN32;_DEBUG;_CONSOLE;_MBCS;WIN32COMMON;_DLL;_MT

    Step 3:
    Project->Properties->Configuration Properties->Linker->Input->Ingore Default Libraries = No

    Step 4:
    Project->Properties->Configuration Properties->General->Common Language Runtime Support = Common Language Runtime Support (/clr)

    Many thanks for the help.

    Rodger
  • 8. Re: error LNK2028: unresolved token (0A00001F) "public: static class oracle....
    gdarling - oracle Expert
    Currently Being Moderated
    For anyone that may find this years down the road like I did, here's the solution:

    1.Right click the project name in Visual Studio
    2. Click Properties
    3. Navigate to Configuration Properties > General
    4. Under Common Language Runtime Support, change the setting from

    Pure MSIL Common Language Runtime Support (/clr:Pure)
    to
    Common Language Runtime Support (/clr).

    5. Clean the solution, and rebuild.