Welcome to MapForums!

Register, sign in, or use Facebook Connect above to join in and participate in the forum.

When you are signed in, this message, the ads in this row, and the red-underlined link ads all go away.

Subscribe to receive our newsletter.
Subscribe Unsubscribe
Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Automation with C++ (Compile OK but Errors in Linking)

This is a discussion on Automation with C++ (Compile OK but Errors in Linking) within the MapPoint Desktop Discussion forums, part of the Map Forums category; I was trying to compile the example code of the article about Automation of Mappoint with C/C++ http://www.mp2kmag.com/a122--c-c++.a....mappoint.html and i ...

  1. #1
    rules is offline Junior Member White Belt
    Join Date
    Aug 2005
    Posts
    8

    Automation with C++ (Compile OK but Errors in Linking)

    I was trying to compile the example code of the article about Automation of Mappoint with C/C++ http://www.mp2kmag.com/a122--c-c++.a....mappoint.html
    and i manage to compile it, but when i do the "Build MapPointApp.exe" Microsoft Visual C++ gives me lots of errors like this:
    Code:
    Linking...
    MapPointApp.obj : error LNK2001: unresolved external symbol "public: long __thiscall MapPoint::_Application::Quit(void)" (?Quit@_Application@MapPoint@@QAEJXZ)
    MapPointApp.obj : error LNK2001: unresolved external symbol "public: void __thiscall MapPoint::_Map::PutSaved(short)" (?PutSaved@_Map@MapPoint@@QAEXF@Z)
    MapPointApp.obj : error LNK2001: unresolved external symbol "public: long __thiscall MapPoint::Pushpin::Delete(void)" (?Delete@Pushpin@MapPoint@@QAEJXZ)
    MapPointApp.obj : error LNK2001: unresolved external symbol "public: long __thiscall MapPoint::_Map::SaveAs(class _bstr_t,enum MapPoint::GeoSaveFormat,short)" (?SaveAs@_Map@MapPoint@@QAEJV_bstr_t@@W4GeoSaveFormat@2@F@Z)
    MapPointApp.obj : error LNK2001: unresolved external symbol "public: long __thiscall MapPoint::_Map::ZoomIn(void)" (?ZoomIn@_Map@MapPoint@@QAEJXZ)
    MapPointApp.obj : error LNK2001: unresolved external symbol "public: long __thiscall MapPoint::Location::GoTo(void)" (?GoTo@Location@MapPoint@@QAEJXZ)
    MapPointApp.obj : error LNK2001: unresolved external symbol "public: void __thiscall MapPoint::Pushpin::PutHighlight(short)" (?PutHighlight@Pushpin@MapPoint@@QAEXF@Z)
    MapPointApp.obj : error LNK2001: unresolved external symbol "public: void __thiscall MapPoint::Pushpin::PutBalloonState(enum MapPoint::GeoBalloonState)" (?PutBalloonState@Pushpin@MapPoint@@QAEXW4GeoBalloonState@2@@Z)
    MapPointApp.obj : error LNK2001: unresolved external symbol "public: void __thiscall MapPoint::Pushpin::PutSymbol(short)" (?PutSymbol@Pushpin@MapPoint@@QAEXF@Z)
    MapPointApp.obj &#58; error LNK2001&#58; unresolved external symbol "public&#58; class _com_ptr_t<class _com_IIID<struct MapPoint&#58;&#58;Pushpin,&struct __s_GUID _GUID_34b0f619_37e1_4c76_a6da_69bf75a5d3de> > __thiscall MapPoint&#58;&#58;_Map&#58;&#58;AddPushpin&#40;struct MapPoint&#58;&#58;Loca
    tion *,class _bstr_t&#41;" &#40;?AddPushpin@_Map@MapPoint@@QAE?AV?$_com_ptr_t@V?$_com_IIID@UPushpin@MapPoint@@$1?_GUID_34b0f619_37e1_4c76_a6da_69bf75a5d3de@@3U__s_GUID@@A@@@@PAULocation@2@V_bstr_t@@@Z&#41;
    MapPointApp.obj &#58; error LNK2001&#58; unresolved external symbol "public&#58; class _com_ptr_t<class _com_IIID<struct IDispatch,&struct __s_GUID _GUID_00020400_0000_0000_c000_000000000046> > __thiscall MapPoint&#58;&#58;FindResults&#58;&#58;GetItem&#40;struct tagVARIANT *&#41;" &#40;?G
    etItem@FindResults@MapPoint@@QAE?AV?$_com_ptr_t@V?$_com_IIID@UIDispatch@@$1?_GUID_00020400_0000_0000_c000_000000000046@@3U__s_GUID@@A@@@@PAUtagVARIANT@@@Z&#41;
    MapPointApp.obj &#58; error LNK2001&#58; unresolved external symbol "public&#58; class _com_ptr_t<class _com_IIID<struct MapPoint&#58;&#58;FindResults,&struct __s_GUID _GUID_188084cf_db96_482b_97a6_2571df9bef81> > __thiscall MapPoint&#58;&#58;_Map&#58;&#58;FindAddressResults&#40;class _bs
    tr_t,class _bstr_t,class _bstr_t,class _bstr_t,class _bstr_t,class _variant_t const &&#41;" &#40;?FindAddressResults@_Map@MapPoint@@QAE?AV?$_com_ptr_t@V?$_com_IIID@UFindResults@MapPoint@@$1?_GUID_188084cf_db96_482b_97a6_2571df9bef81@@3U__s_GUID@@A@@@@V_bstr
    _t@@0000ABV_variant_t@@@Z&#41;
    MapPointApp.obj &#58; error LNK2001&#58; unresolved external symbol "public&#58; class _com_ptr_t<class _com_IIID<struct MapPoint&#58;&#58;_Map,&struct __s_GUID _GUID_90b167c0_923d_4b65_aee2_66938491c916> > __thiscall MapPoint&#58;&#58;_Application&#58;&#58;GetActiveMap&#40;void&#41;" &#40;?GetAc
    tiveMap@_Application@MapPoint@@QAE?AV?$_com_ptr_t@V?$_com_IIID@U_Map@MapPoint@@$1?_GUID_90b167c0_923d_4b65_aee2_66938491c916@@3U__s_GUID@@A@@@@XZ&#41;
    MapPointApp.obj &#58; error LNK2001&#58; unresolved external symbol "public&#58; void __thiscall MapPoint&#58;&#58;_Application&#58;&#58;PutUnits&#40;enum MapPoint&#58;&#58;GeoUnits&#41;" &#40;?PutUnits@_Application@MapPoint@@QAEXW4GeoUnits@2@@Z&#41;
    MapPointApp.obj &#58; error LNK2001&#58; unresolved external symbol "public&#58; void __thiscall MapPoint&#58;&#58;_Application&#58;&#58;PutCaption&#40;class _bstr_t&#41;" &#40;?PutCaption@_Application@MapPoint@@QAEXV_bstr_t@@@Z&#41;
    MapPointApp.obj &#58; error LNK2001&#58; unresolved external symbol "public&#58; void __thiscall MapPoint&#58;&#58;_Application&#58;&#58;PutWindowState&#40;enum MapPoint&#58;&#58;GeoWindowState&#41;" &#40;?PutWindowState@_Application@MapPoint@@QAEXW4GeoWindowState@2@@Z&#41;
    MapPointApp.obj &#58; error LNK2001&#58; unresolved external symbol "public&#58; void __thiscall MapPoint&#58;&#58;_Application&#58;&#58;PutVisible&#40;short&#41;" &#40;?PutVisible@_Application@MapPoint@@QAEXF@Z&#41;
    Debug/MapPointApp.exe &#58; fatal error LNK1120&#58; 17 unresolved externals
    Error executing link.exe.
    
    MapPointApp.exe - 18 error&#40;s&#41;, 0 warning&#40;s&#41;
    Please, can anyone help me? I know if i get this code to work i could do my own but damn Murphy's Law, DAMN IT!!

  2. #2
    Wilfried is offline Senior Member Black Belt
    Join Date
    Nov 2004
    Location
    Belgium
    Posts
    2,433
    Hi,

    As it is unresolved externals given by the linker, it is some obj file that is not linked in. Maybe the typelibrary file ? It should be generated by the IDE and it has to be in the linker options.

    Note that I dont know nor have Microsoft visual C++, so I'm just gueassing.

  3. #3
    hieronymus1 is offline Junior Member White Belt
    Join Date
    Sep 2005
    Posts
    4

    Mappoint in Visual C++ working

    Hi,

    A few years ago I got an working C++ MFC program which embedded the mappoint control. Was not easy I remember. Perhaps I will find it once I search on my harddisk.

  4. #4
    rules is offline Junior Member White Belt
    Join Date
    Aug 2005
    Posts
    8
    I will thank you hieronymus1 if you find that code. I need it for something important.

    About what Wilfried said:

    The type library is called mpna82.tlb and it's in the folder where you install MapPoint. I import it in my code. And the compiler generates two files mpna82.tlh and mpna82.tli that contain definitions of all structs, enums, and so on, and functions to call MapPoint functions, for example:

    LocationPtr Location::GetLocation ( ) {
    struct Location * _result;
    HRESULT _hr = get_Location(&_result);
    if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this));
    return LocationPtr(_result, false);
    }

    is defined in mpna82.tli.

    I don't know how to solve this unresolved external symbol the linker gives me.

    I have another question about the COM programing. Is it possible to compile the C++ app under linux, tu execute it under linux, if you have your mappoint installation mounted on a linux folder? or do this COM interface need to execute on windows necesarylly?

  5. #5
    Wilfried is offline Senior Member Black Belt
    Join Date
    Nov 2004
    Location
    Belgium
    Posts
    2,433
    Hi,

    I'm pretty sure the COM interface has to be on Windows. I dont know about the unresolved externals since I dont know the IDE. Hope you find it.

  6. #6
    ma2005pp is offline Junior Member White Belt
    Join Date
    Sep 2005
    Posts
    5
    I tried this example. After some modification, it works. Following is what I did step by step:

    1. Create a console project in VC6.0
    2. Copy code to files
    ComInterfaces.h
    ComInterfaces.cpp
    MapPointApp.cpp
    3. Build -- lots of errors
    So I add
    Code:
    using namespace MapPoint;
    4. Build again -- 1 error
    I erase ", geoCountryDefault" from the FindAddressResults parameter list
    Build -- No error
    5. Run -- 0x00000005 Access Violation
    I add 5 release() calls at the end of the code, something like
    Code:
    ...
    	myMapPtr->Saved = true;
    
    	pinAddressPtr.Release&#40;&#41;;  
    	locAddressPtr.Release&#40;&#41;;
    	resultsPtr.Release&#40;&#41;;
    	myMapPtr.Release&#40;&#41;;			
    
    	g_pMapPoint->Quit&#40;&#41;;
    	g_pMapPoint.Release&#40;&#41;; 
    
    	CoUninitialize&#40;&#41;;
    &#125;
    6. Run -- OK

  7. #7
    rules is offline Junior Member White Belt
    Join Date
    Aug 2005
    Posts
    8
    I did follow steps 1 to 4. But the erros it gives me building are not when compiling but when linking. I think is a problem of missconfiguration of my IDE, that is, Microsoft VC++6.0. I asked one of my university teachers about it and told me it could be some problem with the PATH system variable but i selected the option "Register environmental variables" when installing. It has to be something very simple and stupid but i don't find it,, damn it.

    But ma2005pp, thanks a lot for you mini-guide, cause i'm sure when i solve these unresolved symbols, i would have found a problem with the access violation. Now i know how to solve that other problem.

  8. #8
    ma2005pp is offline Junior Member White Belt
    Join Date
    Sep 2005
    Posts
    5
    I think you should

    (1) double check the file mpna82.tlb

    On my machine, the file is

    Code:
    C&#58;\WINDOWS\system32>dir "C&#58;\Program Files\Microsoft MapPoint\mpna82.tlb"
     Volume in drive C has no label.
     Volume Serial Number is B058-A879
    
     Directory of C&#58;\Program Files\Microsoft MapPoint
    
    06/20/2003  02&#58;11 AM           134,832 MPNA82.tlb
                   1 File&#40;s&#41;        134,832 bytes
    (2) if there are files mpna82.tlh and mpna82.tli
    in your debug or release folder

    (3) Build the code with map file, and try to find if the missing symbols are in the map file. For example, I could find method "Quit" in my map file

    Code:
    0001&#58;000001d0       ?Quit@_Application@MapPoint@@QAEJXZ 004011d0 f   ComInterfaces.obj

  9. #9
    rules is offline Junior Member White Belt
    Join Date
    Aug 2005
    Posts
    8
    Thanks.

    I have solved the problem. It was some kind of missconfiguration of VC++.
    If any of you are interested in what i'm doing here is my code (working).
    It makes reverse geocoding by an spiral algorithm and also saves the map.
    MapPointApp.cpp
    Code:
    /******************************************
     *										  *
     *  CGI de conversion de coordenadas GPS  *
     *										  *
     ******************************************/
    
    
    #include "ComInterfaces.h"
    #include <stdio.h>
    using namespace MapPoint;
    
    MapPoint&#58;&#58;_ApplicationPtr g_pMapPoint = NULL;
    
    void main&#40; int argc, const char*argv&#91;&#93; &#41;
    &#123;
    	char *endptr;
    	//first and second arguments are latitude and longitude
    	double lat = strtod&#40;argv&#91;1&#93;, &endptr&#41;;
    	double lon = strtod&#40;argv&#91;2&#93;, &endptr&#41;;
     
    	CoInitialize&#40; NULL &#41;;
    
    	/********************
    	 *  Initialization  *
    	 ********************/
    
    	g_pMapPoint.CreateInstance&#40; "MapPoint.Application" &#41;;
    	g_pMapPoint->Visible = false;
    	g_pMapPoint->PutWindowState&#40; geoWindowStateMinimize &#41;;
    	g_pMapPoint->PutCaption&#40; "MapPoint 2004 is in Automation Mode!" &#41;;
    	g_pMapPoint->PutUnits&#40; geoKm &#41;;
    
    	_MapPtr myMapPtr = g_pMapPoint->ActiveMap;
    
    
    	/**********************************
    	 *  Find street name by lat/long  *
    	 **********************************/
    
    	int step = -1;
    	int step_m = -1;
    	int mult = 0;
    	StreetAddressPtr sap;
    	LocationPtr latlongPos;
    
    	LocationPtr latlongPosInicial = myMapPtr->GetLocation&#40;lat,lon,1&#41;;
    	printf&#40;"Position&#40;lat/long&#41;&#58; %s\n", &#40;char*&#41;latlongPosInicial->Name&#41;;
    
    	VARIANT idx;
    	VariantInit&#40; &idx &#41;;
    	V_VT&#40;&idx&#41; = VT_I4;
    	V_I4&#40;&idx&#41; = 1;
    
    	for&#40;int j=0;j<1000;j++&#41;&#123;
    
    		latlongPos = myMapPtr->GetLocation&#40;lat,lon,1&#41;;
    		latlongPos->GoTo&#40;&#41;;
    
    		FindResultsPtr resultsPtr =
    			myMapPtr->ObjectsFromPoint&#40; myMapPtr->LocationToX&#40;latlongPos&#41;,
    									    myMapPtr->LocationToY&#40;latlongPos&#41;&#41;;
    		if&#40;resultsPtr->GetCount&#40;&#41;>0&#41;&#123;
    
    			LocationPtr res = resultsPtr->GetItem&#40; &idx &#41;;
    			sap = res->StreetAddress;
    			if&#40;sap!=NULL&#41;&#123;
    				printf&#40;"Street&#58; %s\n", &#40;char*&#41;sap->GetValue&#40;&#41;&#41;;
    				//latlongPosInicial = res;
    				printf&#40;"Error margin&#58; %.3f Km\n",
                                        llatlongPosInicial->DistanceTo&#40;latlongPos&#41;&#41;;
    				goto found;
    			&#125;
    		&#125;
    		//Increases espiral by 0.00002 degrees
    		step = &#40;step+1&#41;%4;
    		step_m = &#40;step_m+1&#41;%3;
    		if&#40;step_m == 0&#41; mult+=1;
    		switch&#40;step&#41;&#123;
    		case 0&#58;
    			lat+=0.00002*mult;
    			break;
    		case 1&#58;
    			lon+=0.00002*mult;
    			break;
    		case 2&#58;
    			lat-=0.00002*mult;
    			break;
    		case 3&#58;
    			lon-=0.00002*mult;
    			break;
    		&#125;
    	&#125;
    
    	printf&#40;"Street not found\n"&#41;;
    
    found&#58;
    	
    	/******************
    	 *  Map creation  *
    	 ******************/
    
    	PushpinPtr pinAddressPtr = myMapPtr->AddPushpin&#40; latlongPosInicial,
                                                  "You are here"/*nombre_calle*/ &#41;;
    
    	if&#40;sap!=NULL&#41; pinAddressPtr->PutNote&#40;sap->GetValue&#40;&#41;&#41;;
    
    	pinAddressPtr->PutSymbol&#40; 82 &#41;;
    
    	pinAddressPtr->BalloonState = geoDisplayBalloon;
    	pinAddressPtr->Highlight = true;
    
    	myMapPtr->SaveAs&#40; "C&#58;\\MapIsHere", geoFormatHTMLMapAndDirections, false &#41;;
    
    	pinAddressPtr->Highlight = false;
    	pinAddressPtr->BalloonState = geoDisplayBalloon;
    	pinAddressPtr->Delete&#40;&#41;;
    
    	myMapPtr->Saved = true;
    
    	g_pMapPoint->Quit&#40;&#41;;
    
    	CoUninitialize&#40;&#41;;
    	//end
    &#125;
    It is a console application. You pass the latitude and longitude values and then it prints the nearest street, the real distance to the point specified (error margin) and saves the map as an html document.

    Thanks a lot for all your help and for the article about c++ automation.
    Now this works perfect

  10. #10
    Eric Frost's Avatar
    Eric Frost is offline Administrator Black Belt
    Join Date
    Jul 1992
    Posts
    5,094
    Blog Entries
    4
    Thanks for sharing and following up!!

    Eric
    ~ Order MapPoint MapPoint 2013 Here and Get Free Access to the MapForums Downloads ~
    ~~
    ~ Upgrade to Get Access to the MapForums Downloads ~

Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. ImportData and LinkData errors with Delphi 2006
    By stephenmillington in forum MapPoint Desktop Discussion
    Replies: 2
    Last Post: 02-08-2006, 03:30 PM
  2. Help errors
    By spirido in forum MapPoint Desktop Discussion
    Replies: 2
    Last Post: 05-07-2004, 09:30 AM
  3. Garmin StreetPilot III data errors
    By jalesse in forum MapPoint Desktop Discussion
    Replies: 0
    Last Post: 01-01-2004, 12:22 AM
  4. Map location errors in Ireland.
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 07-30-2003, 09:34 PM
  5. Random not ready errors
    By ToddRCS in forum MapPoint Desktop Discussion
    Replies: 3
    Last Post: 11-14-2002, 07:31 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36