U++ framework
Do not panic. Ask here before giving up.

Home » Community » Newbie corner » MSVC 10 to Upp conversion
MSVC 10 to Upp conversion [message #32638] Mon, 30 May 2011 22:22 Go to next message
nlneilson is currently offline  nlneilson
Messages: 644
Registered: January 2010
Location: U.S. California. Mojave &...
Contributor
I am trying to convert a command line app I got working in MSVC 10 into Upp. Then I will make a GUI for it.

It was originally written for Linux in 2005 and a patch for Windows a year or so later. It has not been maintained since then AFAIK.

After making a package in MyApps with the code, making a .cpp file and getting the linking taken of (so far) there were
many warnings regarding deprecation (I think that can be handled).

There were several errors.

I did a search and replace for strcasecmp to strcmp, I can handle the case later.

Here are the remaining errors and the code:
C:\MyApps\GUItiler\tilepack.cpp(61) : error C2065: 'DIR' : undeclared identifier
C:\MyApps\GUItiler\tilepack.cpp(61) : error C2065: 'd' : undeclared identifier
C:\MyApps\GUItiler\tilepack.cpp(66) : error C2065: 'd' : undeclared identifier
C:\MyApps\GUItiler\tilepack.cpp(66) : error C3861: 'opendir': identifier not found
C:\MyApps\GUItiler\tilepack.cpp(67) : error C2065: 'd' : undeclared identifier
C:\MyApps\GUItiler\tilepack.cpp(68) : error C2065: 'd' : undeclared identifier
C:\MyApps\GUItiler\tilepack.cpp(68) : error C3861: 'readdir': identifier not found
C:\MyApps\GUItiler\tilepack.cpp(68) : fatal error C1903: unable to recover from previous error(s); st
	opping compilation

// code that throws the errors

void ScanDatasetR(const char *path) {
    DIR *d;
    struct dirent *de;
    int l, x, y;
    string s;

    d = opendir(path);
    if (!d) return;
    while (de = readdir(d)) {
        if ((de->d_type == DT_DIR) && (de->d_name[0] != '.')) ScanDatasetR((string(path) + string(de->d_name) + "/").c_str());
        if (de->d_type == DT_REG) {
            s = de->d_name;
            if (sscanf(s.substr(0, 2).c_str(), "%x", &l) && sscanf(s.substr(2, 8).c_str(), "%x", &x) && sscanf(s.substr(10, 8).c_str(), "%x", &y)) {
		bm[(static_cast<unsigned __int64>(l) << 50) + (static_cast<unsigned __int64>(y >> 7) << 25) + (x >> 7)].push_back((x & 0x7f) + ((y & 0x7f) << 7));
            }
        }
    }
    closedir(d);
}


I am not that proficient with pointers so help would be appreciated.

With the " unable to recover from previous error(s); stopping compilation" there will probably be more later but just taking it a step at a time.

edit: I don't want to use MSVC for the GUI or anything else if it can be avoided.
I like Upp.

[Updated on: Mon, 30 May 2011 22:43]

Report message to a moderator

Re: MSVC 10 to Upp conversion [message #32639 is a reply to message #32638] Mon, 30 May 2011 22:54 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3460
Registered: August 2008
Senior Veteran
Hello Neil

If you know what that function does it is very easy to translate it to U++.


Best regards
Iñaki
Re: MSVC 10 to Upp conversion [message #32640 is a reply to message #32639] Mon, 30 May 2011 23:05 Go to previous messageGo to next message
nlneilson is currently offline  nlneilson
Messages: 644
Registered: January 2010
Location: U.S. California. Mojave &...
Contributor
Here is a .zip of that package ~2MB.
http://www.nlneilson.com/apps/GUItiler.zip

I think ScanDatasetR is the list of files that will be tiled.

Forgot to mention this links to FWTools 2.4.7 /include and /lib
http://fwtools.maptools.org/

and also in INCLUDE directories
C:\MyApps\GUItiler\win32dummy
C:\MyApps\GUItiler\win32dummy\sys

[Updated on: Mon, 30 May 2011 23:41]

Report message to a moderator

Re: MSVC 10 to Upp conversion [message #32642 is a reply to message #32640] Tue, 31 May 2011 01:39 Go to previous messageGo to next message
nlneilson is currently offline  nlneilson
Messages: 644
Registered: January 2010
Location: U.S. California. Mojave &...
Contributor
Doing a google search, this forum and the Upp Help I came up with a few possibilities.

opendir is a C++ function in the direct.h header

In Upp apparently that is only functions defined in an app
MSVC picked up the C++ opendir but Upp does not.

#include <direct.h>
Adding this to tilepack.cpp and in the .upp file didn't help but didn't give an error for the #include.

In Upp 3470 after setting up the links in both and compiling with MSC9 and MSC10 the results were the same.

[Updated on: Tue, 31 May 2011 02:37]

Report message to a moderator

Re: MSVC 10 to Upp conversion [message #32643 is a reply to message #32642] Tue, 31 May 2011 04:43 Go to previous messageGo to next message
nlneilson is currently offline  nlneilson
Messages: 644
Registered: January 2010
Location: U.S. California. Mojave &...
Contributor
opendir just iterates through all files in a directory and sub directories.

There must be some function in Upp that does this.

Re: MSVC 10 to Upp conversion [message #32645 is a reply to message #32643] Tue, 31 May 2011 08:03 Go to previous messageGo to next message
dolik.rce is currently offline  dolik.rce
Messages: 1796
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

nlneilson wrote on Tue, 31 May 2011 04:43

opendir just iterates through all files in a directory and sub directories.

There must be some function in Upp that does this.
FindFile object is usually used for this, something like:
void IterateThroughDirs(const String& dir){
	for(FindFile ff(AppendFileName(dir, "*")); ff; ff.Next()) {
		if(ff.IsFolder())
			IterateThroughDirs(ff.GetName()); // call itself on the subdirectory
		else if(ff.IsFile()) {
			// process the file ff.GetName() here
		}
	}
}

Honza
Re: MSVC 10 to Upp conversion [message #32648 is a reply to message #32645] Tue, 31 May 2011 08:40 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3460
Registered: August 2008
Senior Veteran
Hello Neil

Using Honza code and replacing this stuff:

if (sscanf(s.substr(0, 2).c_str(), "%x", &l) && sscanf(s.substr(2, 8).c_str(), "%x", &x) && sscanf(s.substr(10, 8).c_str(), "%x", &y)) {
		bm[(static_cast<unsigned __int64>(l) << 50) + (static_cast<unsigned __int64>(y >> 7) << 25) + (x >> 7)].push_back((x & 0x7f) + ((y & 0x7f) << 7));
            }

with some more readable U++ code you will have it all, and more portable Smile.


Best regards
Iñaki
Re: MSVC 10 to Upp conversion [message #32649 is a reply to message #32648] Tue, 31 May 2011 12:29 Go to previous messageGo to next message
nlneilson is currently offline  nlneilson
Messages: 644
Registered: January 2010
Location: U.S. California. Mojave &...
Contributor
Thanks Honza and Koldo

I use something like your example in Java, this just counts but is about the same for processing files rather than tNum++;
It's just a simple loop back if it's a directory rather than a file.

    private void countFiles(File sourceDirectory){
    	for (File f : sourceDirectory.listFiles()) {
    		if (f.isDirectory()) countFiles(f);
    		if (f.isFile()) tNum++;
    	}
    }

I thought there may be something like the dos findfirst-findnext, Python Walk, etc. rolled into a function like opendir in Upp
or being able to use opendir, I thought that was a C++ function.

Those two lines do look complicated but breaks down to
    if(... && ... && ...){
        ...;
    }

This is mostly with numbers which I am fair with or file names.
That shouldn't be a problem unless Upp doesn't use sscanf, static_cast, push_back, etc..

I will get it to iterate through the files and see what happens.

[Updated on: Tue, 31 May 2011 12:39]

Report message to a moderator

Re: MSVC 10 to Upp conversion [message #32659 is a reply to message #32649] Tue, 31 May 2011 21:20 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3460
Registered: August 2008
Senior Veteran
Hello Neil

For example I would replace

string s;
int l;
...
sscanf(s.substr(0, 2).c_str(), "%x", &l)


with

String s;
int l;
...
l = ScanInt(s.Mid(0, 2), 0, 16);



Best regards
Iñaki
Re: MSVC 10 to Upp conversion [message #32660 is a reply to message #32659] Tue, 31 May 2011 22:06 Go to previous messageGo to next message
nlneilson is currently offline  nlneilson
Messages: 644
Registered: January 2010
Location: U.S. California. Mojave &...
Contributor
Hi Koldo

Thanks for the suggestion.

There are many changes I would like to make or may to need to change to get it to compile.

"l = ScanInt(s.Mid(0, 2), 0, 16);" does look much better.

Searching the package for "opendir" there is only the one instance.
Will get that changed today.
Re: MSVC 10 to Upp conversion [message #32662 is a reply to message #32660] Wed, 01 June 2011 02:59 Go to previous messageGo to next message
nlneilson is currently offline  nlneilson
Messages: 644
Registered: January 2010
Location: U.S. California. Mojave &...
Contributor
Finally got around to starting the changes to iterate through the files and noticed that has all ready been done with findfirst/findnext.
I used the original tilepack.cpp and tinkered with these without any luck.

#ifdef WIN32
#else
#endif

Does Upp treat these differently?

#ifdef WIN32
void ScanDatasetR(const char *path) {
    struct _finddata_t c_file;
    long hFile;
    int l, x, y;
    string s;
    string filespec;

    filespec = string(path) + "\\*.*";

    hFile = _findfirst( filespec.c_str(), &c_file );  // _findfirst
    if( hFile == -1L )
        return;
    do { 
        if ((c_file.attrib & _A_SUBDIR) && (c_file.name[0] != '.')) 
            ScanDatasetR((string(path) + string(c_file.name) + "\\").c_str());
        else if (c_file.attrib & _A_NORMAL) {
            s = c_file.name;
            if (sscanf(s.substr(0, 2).c_str(), "%x", &l) && sscanf(s.substr(2, 8).c_str(), "%x", &x) && sscanf(s.substr(10, 8).c_str(), "%x", &y)) {
		bm[(static_cast<unsigned __int64>(l) << 50) + (static_cast<unsigned __int64>(y >> 7) << 25) + (x >> 7)].push_back((x & 0x7f) + ((y & 0x7f) << 7));
            }
        }
    } while( _findnext( hFile, &c_file) == 0 );  // _findnext
    _findclose( hFile );
}
#else
void ScanDatasetR(const char *path) {
    DIR *d;
    struct dirent *de;
    int l, x, y;
    string s;

    d = opendir(path);  // opendir
    if (!d) return;
    while (de = readdir(d)) {
        if ((de->d_type == DT_DIR) && (de->d_name[0] != '.')) ScanDatasetR((string(path) + string(de->d_name) + "/").c_str());
        if (de->d_type == DT_REG) {
            s = de->d_name;
            if (sscanf(s.substr(0, 2).c_str(), "%x", &l) && sscanf(s.substr(2, 8).c_str(), "%x", &x) && sscanf(s.substr(10, 8).c_str(), "%x", &y)) {
		bm[(static_cast<unsigned __int64>(l) << 50) + (static_cast<unsigned __int64>(y >> 7) << 25) + (x >> 7)].push_back((x & 0x7f) + ((y & 0x7f) << 7));
            }
        }
    }
    closedir(d);
}
#endif


edit: I did a search in the package for WIN32
Other than in tilepack.cpp the only other is in the main (GUItiler.cpp)
#ifndef WIN32
  • Attachment: tilepack.cpp
    (Size: 4.15KB, Downloaded 419 times)

[Updated on: Wed, 01 June 2011 05:20]

Report message to a moderator

Re: MSVC 10 to Upp conversion [message #32663 is a reply to message #32662] Wed, 01 June 2011 08:06 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3460
Registered: August 2008
Senior Veteran
Hello Neil

For me it is very easy to convert the _findfirst, _findnext, _findclose to FindFile class as indicated by Honza, ad the code is more clear.


Best regards
Iñaki
Re: MSVC 10 to Upp conversion [message #32665 is a reply to message #32663] Wed, 01 June 2011 08:37 Go to previous messageGo to next message
nlneilson is currently offline  nlneilson
Messages: 644
Registered: January 2010
Location: U.S. California. Mojave &...
Contributor
Hi Koldo

Yes that would be clear and many things will be changed once I can compile and run it.

Apparently I got over the iterate files issue.

I found these links:
http://www.mail-archive.com/fossil-users@lists.fossil-scm.or g/msg02331.html
http://msdn.microsoft.com/en-us/library/b0084kay.aspx

Put an underscore before each WIN32 to _WIN32

No error as before.

Now I have
tilepack.obj : error LNK2005: _main already defined in GUItiler.obj
Creating library C:\upp\out\MyApps\MSC9.Gui.Mt\GUItiler.lib and object C:\upp\out\MyApps\MSC9.Gui.Mt\GUItiler.exp

and
"fatal error LNK1120: 117 unresolved externals"

At least I am not getting "unable to recover from previous error(s); stopping compilation"

Re: MSVC 10 to Upp conversion [message #32668 is a reply to message #32665] Wed, 01 June 2011 10:10 Go to previous messageGo to next message
nlneilson is currently offline  nlneilson
Messages: 644
Registered: January 2010
Location: U.S. California. Mojave &...
Contributor
This is what this app does:

1. Change the format of geo-referenced images to WSG84 if necessary.

2. Merge many images into one big mosaic.

3. Tiles the large image into a tiled pyramid for different resolutions of 512x512 pixels. The highest resolution level has the same resolution as the original images. Then 4 of those images are made into a one step lower resolution and so on.
This is the way it is done for Google Earth and many others.

All of this I can do directly with FWTools or OSGeo4W

EXCEPT the tiling and overviews.

The lowest level of resolution (lztd) default size is 180 degrees with gdal2tiles, which is a pain and often some resolution is lost.

The images I use most are the U.S. FAA Charts and I have been using dstile to tile them with and can specify the lztd (LevelZeroTileDelta) as 1, 2, 5 or 10 deg.
The NASA WorldWind project uses an lztd of 36 deg for Satellite images.

Part of a response from the person that patched the original dstile to work in Windows was this:
Quote:

I suggest letting dstile fall into legacy and using this route instead.

The "new" way is geared toward smaller images, doing it on the fly and NO control over the lztd.

I tinkered with gdal2tiles for several days and got that to work for the format and naming convention but the resolution was less and that was only with an lztd of 180 deg.

It took some time to get the code to compile and run in MSVC 10 but I don't want to get tied into that to make changes.

Maybe if I can get the linking problems resolved I can do this in Upp which I prefer.
Re: MSVC 10 to Upp conversion [message #32671 is a reply to message #32668] Wed, 01 June 2011 11:29 Go to previous messageGo to next message
nlneilson is currently offline  nlneilson
Messages: 644
Registered: January 2010
Location: U.S. California. Mojave &...
Contributor
Here are a few of the errors I am getting.
I have everything linked I can think of, include, lib, bin
These all seem to be in FWtools and I shouldn't have to get in there and change code.
Maybe it's time to give this attempt a rest.

Tiler.obj : error LNK2001: unresolved external symbol "public: class GDALDataset * __thiscall GDALDri
	ver::Create(char const *,int,int,int,enum GDALDataType,char * *)" (?Create@GDALDriver@@QAEPAVGDAL
	Dataset@@PBDHHHW4GDALDataType@@PAPAD@Z)
Overviews.obj : error LNK2019: unresolved external symbol "public: enum GDALDataType __thiscall GDALR
	asterBand::GetRasterDataType(void)" (?GetRasterDataType@GDALRasterBand@@QAE?AW4GDALDataType@@XZ) 
	referenced in function "protected: void __thiscall Overviews::BuildOverviewsR(class TileTree::Nod
	e *,int,int,int)" (?BuildOverviewsR@Overviews@@IAEXPAVNode@TileTree@@HHH@Z)
TileProcessor.obj : error LNK2001: unresolved external symbol "public: enum GDALDataType __thiscall G
	DALRasterBand::GetRasterDataType(void)" (?GetRasterDataType@GDALRasterBand@@QAE?AW4GDALDataType@@
	XZ)
Overviews.obj : error LNK2019: unresolved external symbol "public: class GDALRasterBand * __thiscall 
	GDALDataset::GetRasterBand(int)" (?GetRasterBand@GDALDataset@@QAEPAVGDALRasterBand@@H@Z) referenc
	ed in function "protected: void __thiscall Overviews::BuildOverviewsR(class TileTree::Node *,int,
	int,int)" (?BuildOverviewsR@Overviews@@IAEXPAVNode@TileTree@@HHH@Z)
TileProcessor.obj : error LNK2001: unresolved external symbol "public: class GDALRasterBand * __thisc
	all GDALDataset::GetRasterBand(int)" (?GetRasterBand@GDALDataset@@QAEPAVGDALRasterBand@@H@Z)
Tiler.obj : error LNK2001: unresolved external symbol "public: class GDALRasterBand * __thiscall GDAL
	Dataset::GetRasterBand(int)" (?GetRasterBand@GDALDataset@@QAEPAVGDALRasterBand@@H@Z)
Overviews.obj : error LNK2019: unresolved external symbol "public: int __thiscall GDALDataset::GetRas
	terCount(void)" (?GetRasterCount@GDALDataset@@QAEHXZ) referenced in function "protected: void __t
	hiscall Overviews::BuildOverviewsR(class TileTree::Node *,int,int,int)" (?BuildOverviewsR@Overvie
	ws@@IAEXPAVNode@TileTree@@HHH@Z)
TileProcessor.obj : error LNK2001: unresolved external symbol "public: int __thiscall GDALDataset::Ge
	tRasterCount(void)" (?GetRasterCount@GDALDataset@@QAEHXZ)
Warper.obj : error LNK2001: unresolved external symbol "public: int __thiscall GDALDataset::GetRaster
	Count(void)" (?GetRasterCount@GDALDataset@@QAEHXZ)
Overviews.obj : error LNK2019: unresolved external symbol "public: int __thiscall GDALDataset::GetRas
	terYSize(void)" (?GetRasterYSize@GDALDataset@@QAEHXZ) referenced in function "protected: void __t
	hiscall Overviews::BuildOverviewsR(class TileTree::Node *,int,int,int)" (?BuildOverviewsR@Overvie
	ws@@IAEXPAVNode@TileTree@@HHH@Z)
TileProcessor.obj : error LNK2001: unresolved external symbol "public: int __thiscall GDALDataset::Ge
	tRasterYSize(void)" (?GetRasterYSize@GDALDataset@@QAEHXZ)
Overviews.obj : error LNK2019: unresolved external symbol "public: int __thiscall GDALDataset::GetRas
	terXSize(void)" (?GetRasterXSize@GDALDataset@@QAEHXZ) referenced in function "protected: void __t
	hiscall Overviews::BuildOverviewsR(class TileTree::Node *,int,int,int)" (?BuildOverviewsR@Overvie
	ws@@IAEXPAVNode@TileTree@@HHH@Z)
TileProcessor.obj : error LNK2001: unresolved external symbol "public: int __thiscall GDALDataset::Ge
	tRasterXSize(void)" (?GetRasterXSize@GDALDataset@@QAEHXZ)
Overviews.obj : error LNK2019: unresolved external symbol "public: class GDALDriver * __thiscall GDAL
	DriverManager::GetDriverByName(char const *)" (?GetDriverByName@GDALDriverManager@@QAEPAVGDALDriv
	er@@PBD@Z) referenced in function "public: __thiscall
Re: MSVC 10 to Upp conversion [message #32674 is a reply to message #32671] Wed, 01 June 2011 12:09 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3460
Registered: August 2008
Senior Veteran
Hello Neil

The compiler errors in your message are very related to the external library you want to include.

For trying to help you please send a file with all inside ready to be compiled (U++, packages, external includes, libs, dlls, ...). If the compressed size is big to be posted you can put the file in some public file server.


Best regards
Iñaki
Re: MSVC 10 to Upp conversion [message #32675 is a reply to message #32674] Wed, 01 June 2011 12:35 Go to previous messageGo to next message
nlneilson is currently offline  nlneilson
Messages: 644
Registered: January 2010
Location: U.S. California. Mojave &...
Contributor
Hi Koldo

Here is a .zip as of today.
http://www.nlneilson.com/apps/GUItiler.zip ~2MB

This is what it is linked to, FWTools 2.4.7
http://home.gdal.org/fwtools/FWTools247.exe ~22MB
I have this installed on C:\FWTools2.4.7
If you all ready have that installed somewhere else just change the build paths.

Thanks for looking at it, I felt I was running into a dead end street.

edit: If it would be of any help for checking the links or whatever I zipped and uploaded the MSVC 10 package.
http://www.nlneilson.com/apps/DsTileQtGUI.zip ~21MB
That also links to FWTools.

[Updated on: Wed, 01 June 2011 13:16]

Report message to a moderator

Re: MSVC 10 to Upp conversion [message #32680 is a reply to message #32675] Wed, 01 June 2011 17:19 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3460
Registered: August 2008
Senior Veteran
Hello Neil

Include fixed package. It runs using MSC9 (because of the libs) but compiles in MinGW too.

Look to the changes, many of them labeled with "// KOLDO".

The original source uses std and many linux functions.

Look at the main(). It is replaced with a GUI_APP_MAIN but without handling command line args (this work is for you Smile).

Package organizer has been changed too, adding the libs.

Please include the include, lib and bin ("executable directories") paths in "Build methods".

The changes have been rough, just to compile and run. Now you would have to polish it all, giving the package a nice U++ style Smile.

  • Attachment: GUItiler.7z
    (Size: 333.96KB, Downloaded 338 times)


Best regards
Iñaki
Re: MSVC 10 to Upp conversion [message #32684 is a reply to message #32680] Wed, 01 June 2011 23:05 Go to previous messageGo to next message
nlneilson is currently offline  nlneilson
Messages: 644
Registered: January 2010
Location: U.S. California. Mojave &...
Contributor
Great!

Much appreciated.

Adam Nowacki (nowak) did the original code for Linux and Tisham Dhar (whatnick) did the
conversion to work with Windows.
That is why the Linux code is still there.

The command line args are straight forward, most are just passed to GDAL.
The main arg I was concerned about is for the tile size.
gdal2tiles ONLY handles an lztd of 180 deg, dstile takes an arg for the size.

Now I can make a Upp GUI that handles the args and does some pre-checking.
To merge and tile 74 images it may take 5 hours.
To have it kick out because of a problem with one of the last few images is a pain,
the set has to be done as a whole.

Thanks Koldo!
Re: MSVC 10 to Upp conversion [message #32685 is a reply to message #32684] Thu, 02 June 2011 00:41 Go to previous messageGo to next message
nlneilson is currently offline  nlneilson
Messages: 644
Registered: January 2010
Location: U.S. California. Mojave &...
Contributor
Hi Koldo

Your package compiled the first time without errors, great.

A few changes I noticed was
#include "win32dummy/unistd.h"
#include "win32dummy/dirent.h"
and in the .upp file
library
	"bgd gdal_i geos_i geotiff_i iconv libtiff_i libxml2 mapserver_i ogdi_32b1 ogdi_fw proj_i";

That all make sense but would not have figured that out myself.

The number of arg can be quite large like this:
dstile.exe tile --lztsd 10.0 --wwcache --overviews 48States HalifaxN.tif HalifaxS.tif MontrealN.tif MontrealS.tif ...

for the images/files to be merged and tiled (I often do 74) plus ~6 more options in the existing code
and I will be adding a few more with changes.
With no args it just lists the options.
I can handle that.

The biggest problem was getting the existing code to compile in Upp.

It will be interesting to see what other changes you have made.

Thanks again.


Re: MSVC 10 to Upp conversion [message #32689 is a reply to message #32685] Thu, 02 June 2011 08:36 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3460
Registered: August 2008
Senior Veteran
Hello Neil

- About win32dummy
After trying unsuccessfully to compile the package with MSC I realize there was that folder with include files designed for MSC and windows in general so I just used it. Then MSC compiled well.

- About the library
In Build methods you say the compiler in which folders are the libraries, but in Package organizer you say the compiler which are the libraries to use.

- About the arg list
It is very easy. Just use CommandLine(). It returns a Vector<String>& with all the args.


Best regards
Iñaki
Re: MSVC 10 to Upp conversion [message #32695 is a reply to message #32689] Thu, 02 June 2011 11:12 Go to previous messageGo to next message
nlneilson is currently offline  nlneilson
Messages: 644
Registered: January 2010
Location: U.S. California. Mojave &...
Contributor
Hi Koldo

It's good you got it to compile in MSC. I had links according to my setup.

Quote:

- About the library
In Build methods you say the compiler in which folders are the libraries, but in Package organizer you say the compiler which are the libraries to use.


I am a bit confused on this. In theIDE I did have to set the Build paths with Setup->Build methods for MSC9
and then do the same for MSC10. By "Package organizer" are you referring to the .upp file?

About the args the change from
int main(int argc, char *argv[]) {
to
GUI_APP_MAIN 
{

was a bit of a change as I am not used to that.

The glitch I am having now is with no arguments.
How this app is set up to work is the dstile.exe or Guitiler.exe is placed in the FWTools bin directory.

Then the FWTools dos box is opened and then dstile.exe plus any options are typed on the command line.

If just dstile.exe with no args then just the 5 lines as from the code at lines #232 to #236 are printed:
"RUN: %s command ...\n"
" tile\n"
" overviews\n
" prep\n"
" pack\n"

The dstile.exe from your MSC compile should work that way.

My GUItiler.exe from the U++ compile does not.
even after setting argv[0] and argv[1] = "";


[Updated on: Thu, 02 June 2011 11:22]

Report message to a moderator

Re: MSVC 10 to Upp conversion [message #32697 is a reply to message #32695] Thu, 02 June 2011 11:37 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3460
Registered: August 2008
Senior Veteran
Hello Neil

It's good you got it to compile in MSC.
More than that. It only links with MSC.

By "Package organizer" are you referring to the .upp file?
In Project/Package organizer menu or by right clicking the package in the left vertical window you have the compiling and linking options and libraries. All those settings are saved in .upp file Smile.

About command line management, just use U++ CommandLine() and remove all references to argc and argv[]. It is documented and works very well.


Best regards
Iñaki
Re: MSVC 10 to Upp conversion [message #32699 is a reply to message #32695] Thu, 02 June 2011 12:21 Go to previous messageGo to next message
nlneilson is currently offline  nlneilson
Messages: 644
Registered: January 2010
Location: U.S. California. Mojave &...
Contributor
Hi Koldo

I will see what documentation and examples I can find on "CommandLine()"

Did you try your U++ compiled GUItiler.exe in FWTools without args and get the 5 lines printed?

I don't understand what you mean by this:
Quote:

More than that. It only links with MSC.

There a functions in the dstile code that relies on the FWTools code.

[Updated on: Thu, 02 June 2011 13:26]

Report message to a moderator

Re: MSVC 10 to Upp conversion [message #32701 is a reply to message #32699] Thu, 02 June 2011 13:15 Go to previous messageGo to next message
nlneilson is currently offline  nlneilson
Messages: 644
Registered: January 2010
Location: U.S. California. Mojave &...
Contributor
merged to previous post

[Updated on: Thu, 02 June 2011 13:29]

Report message to a moderator

Re: MSVC 10 to Upp conversion [message #32702 is a reply to message #32701] Thu, 02 June 2011 13:53 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3460
Registered: August 2008
Senior Veteran
Hello Neil

With MinGW I get a lot of linking problems.


Best regards
Iñaki
Re: MSVC 10 to Upp conversion [message #32714 is a reply to message #32702] Fri, 03 June 2011 01:54 Go to previous messageGo to next message
nlneilson is currently offline  nlneilson
Messages: 644
Registered: January 2010
Location: U.S. California. Mojave &...
Contributor
Hi Koldo

I decided to go a slightly different route.
I will make the U++ GUI in a separate app that will call the .exe from the existing code.

I renamed the existing package to ntile and replaced the
int main(int argc, char *argv[]) {

I understand that better.

Other than that I just pulled the ntile.cpp into Eclipse to correct the indentation.

Compiling in U++ I just get one link error:
LIBCMT.lib(wincrt0.obj) : error LNK2019: unresolved external symbol _WinMain@16 referenced in function
	 ___tmainCRTStartup



http://www.nlneilson.com/apps/ntile.zip
Re: MSVC 10 to Upp conversion [message #32715 is a reply to message #32714] Fri, 03 June 2011 03:26 Go to previous messageGo to next message
nlneilson is currently offline  nlneilson
Messages: 644
Registered: January 2010
Location: U.S. California. Mojave &...
Contributor
Hi Koldo

I did a google searce for "tmainCRTStartup" and found this:
http://social.msdn.microsoft.com/Forums/en/vclanguage/thread /14e85604-6929-4707-a22e-8cdf596926a6

In theIDE I clicked on the box that has "GUI MT and deleted the GUI.

It compiled without errors and opened a dos box and displayed the 5 lines mentioned above.

Thanks for the help, couldn't have done it on my own.

edit: Tried to merge and tile 2 images.
It started OK and displayed the args as it should then crashed.
Still have a few bugs to work out.

[Updated on: Fri, 03 June 2011 03:45]

Report message to a moderator

Re: MSVC 10 to Upp conversion [message #32735 is a reply to message #32715] Sun, 05 June 2011 04:05 Go to previous messageGo to next message
nlneilson is currently offline  nlneilson
Messages: 644
Registered: January 2010
Location: U.S. California. Mojave &...
Contributor
Hi Koldo

I have a U++ GUI.

http://www.nlneilson.com/wwposts/N_tile_1.jpg

Work Dir is where the image files are that can be found with a file selector.
Out is a directory name typed in to save the tiled images to.
FWTools\bin shows if that can be linked, I have it at C:\ and some install under Program Files.
LZTD is where a value can be typed in.
OverViews is a button on by default that can be toggled if only the highest resolution is to be tiled rather than all levels.
File list is for the files to be merged and tiles. This just pulls up list or makes a list from a text file. The list is usually much longer than the text box but can be scrolled or obtained with "select all->copy". If the files have been previously merged then there will only be one file shown.
Before processing the file list will be checked to see if all files are available.

I have not been able to get the converted code to work yet.
It's difficult to debug into files that are linked from FWTools but I can use the dstile.exe until getting the converted code to run in U++, that is where I would like to make changes in the code. I will try adding print statements to track the bug/s down.

It compiles without error (ntile.exe), passes the command line args to FWTools then Win crashes the app.

http://www.nlneilson.com/wwposts/ntile_1.jpg

The dstile.exe, the original or the dstile.exe compiled with MSVC 10 works OK.

http://www.nlneilson.com/wwposts/dstile_1.jpg

If will I try the "CommandLine()" in U++.
Some IDEs have an option to specify the command line args, how is that done in U++ (theIDE)?

[Updated on: Sun, 05 June 2011 05:10]

Report message to a moderator

Re: MSVC 10 to Upp conversion [message #32736 is a reply to message #32735] Sun, 05 June 2011 05:38 Go to previous messageGo to next message
nlneilson is currently offline  nlneilson
Messages: 644
Registered: January 2010
Location: U.S. California. Mojave &...
Contributor
Compiled in debug mode I get an error that says in the MS error box:
Debug Assertion Failed!
Program: C:\FWTool~1.7\bin\ntile
File: f:dd\vctools\crt\self_x86\crt\src\close.c
Line: 47

Expression: (fh >=0&&(unsigned)fh <(unsigned)_nhandle)

I also tried this after copying HalifaxN.tif to the U++ output directory like I often do in Python for testing:
int main(int argc, char *argv[]) {
// --lztsd 10.0 --wwcache --overviews 0nt HalifaxN.tif	
	argc = 8;
	argv[0] = "ntile";
	argv[1] = "tile";
	argv[2] = "--lztsd";
	argv[3] = "10.0";
	argv[4] = "--wwcache";
	argv[5] = "--overviews";
	argv[6] = "0nt";
	argv[7] = "HalifaxN.tif";

I get the same error as above.
Another issue doing it this way or with the U++ "CommandLine()" is
this opens in a regular dos box rather than the FWTools dos box.

[Updated on: Sun, 05 June 2011 06:19]

Report message to a moderator

Re: MSVC 10 to Upp conversion [message #32737 is a reply to message #32736] Sun, 05 June 2011 06:58 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3460
Registered: August 2008
Senior Veteran
Hello Neil

To set program command line goto Debug/Run options/Program arguments.


Best regards
Iñaki
Re: MSVC 10 to Upp conversion [message #32741 is a reply to message #32737] Sun, 05 June 2011 10:35 Go to previous messageGo to next message
nlneilson is currently offline  nlneilson
Messages: 644
Registered: January 2010
Location: U.S. California. Mojave &...
Contributor
Thanks Koldo

That will help because each time a test run is made the output directory needs to be changed, 0nt1, 0nt2, 0nt3, etc..

I just spent a couple hours brushing up and testing dos commands,
that is similar to how the GUI will act for processing.

call "C:\FWTools2.4.7\setfw.bat" /K is all that is required to set up that environment.
Re: MSVC 10 to Upp conversion [message #32759 is a reply to message #32741] Mon, 06 June 2011 23:57 Go to previous messageGo to next message
nlneilson is currently offline  nlneilson
Messages: 644
Registered: January 2010
Location: U.S. California. Mojave &...
Contributor
Hi Koldo

I am able to debug into the code now after hard coding the args and setting the environment with:
	system ("C:/FWTools2.4.7/setfw.bat /K");


I have a U++ GUI I can later tie into this. (Honza helped with SelectDirectory()Wink

Where I am getting the crash is at ~#164 Tiler.cpp
fl.Open(loc);

loc at that point is correct, a portion is "... _Ptr=2190390 "0nt/5/0442/0442_0351.jpg"..."
I don't know how or if that full line can be copied in U++.

With this placed just before the problem line
printf("%s", loc);
fl.Open(loc);
it prints <NULL>.

fl.open goes into syskit.cpp FileLock::Open where "fileName" parameter loc) is OK.
if (m_fd) close(m_fd);
is where it actually crashes.

If I comment that line out it seem to run OK for the base images.
When it gets to tiling the lower resolutions it crashes, probably just need to comment a line there also.

Is there something in U++ that is needed to lock/unlock?

[Updated on: Tue, 07 June 2011 01:23]

Report message to a moderator

Re: MSVC 10 to Upp conversion [message #32761 is a reply to message #32759] Tue, 07 June 2011 07:17 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3460
Registered: August 2008
Senior Veteran
Hello Neil

I do not understand this:
Quote:

a portion is "... _Ptr=2190390 "0nt/5/0442/0442_0351.jpg"..."
I don't know how or if that full line can be copied in U++.


What is the problem?

About the rest it would be great if you could upload a simple sample package with it.


Best regards
Iñaki
Re: MSVC 10 to Upp conversion [message #32763 is a reply to message #32759] Tue, 07 June 2011 07:45 Go to previous messageGo to next message
nlneilson is currently offline  nlneilson
Messages: 644
Registered: January 2010
Location: U.S. California. Mojave &...
Contributor
In other IDEs a full line of text in the "Console" can be selected and copied. I don't know how that is done in U++.
So I just posted the pertinent part of that line.
I could upload the package but to run it needs a .tif file.
I will zip up the package and a small .tif (1.5MB) to test with.
The .tif files I usually work with are ~140MB.
It may take a few minutes to get that done and will edit this post with the link.

edit: Here is a .zip, it just replaces the previous:
http://www.nlneilson.com/apps/ntile.zip
In Debug->Options Working directory change that to where you place the .tif file.
In ntile.cpp #227 replace the location you have installed FWTools, the .bat file name should be the same and it needs the /K

In a few hours I will be heading up to my Ranch/Farm for a few days.


Apparently this cannot be debugged into the
FWTools/gdal code.

The MS crash box showed an error re assertion and close.
commented all the code that had "close" with small 'c'.

Runs OK with the overviews.
It does give a warning: Heap leaks detected !

Seems strange but if U++ can run it without problems it,s OK. Very Happy

Now back to the GUI and tying that in.

One of the things I wanted to change in the original code was found and changed.

Thanks for the help Koldo.

[Updated on: Tue, 07 June 2011 08:30]

Report message to a moderator

Re: MSVC 10 to Upp conversion [message #32773 is a reply to message #32763] Tue, 07 June 2011 15:59 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3460
Registered: August 2008
Senior Veteran
Hello Neil

Program compiles well but I get this error:
ERROR 4: Unable to open EPSG support file gcs.csv.
Try setting the GDAL_DATA environment variable to point to the
directory containing EPSG csv files.
:

After playing with .bat files, I tried to force GDAL_DATA to the right folder, but the error always appear.


Best regards
Iñaki
Re: MSVC 10 to Upp conversion [message #32785 is a reply to message #32773] Thu, 09 June 2011 10:38 Go to previous messageGo to next message
nlneilson is currently offline  nlneilson
Messages: 644
Registered: January 2010
Location: U.S. California. Mojave &...
Contributor
Hi Koldo

We just got back tonight as something came up and had to get back early.

That is strange, I have not seen that error before.
I will look at that tomorrow.

Here is a .zip of ntile and also the GUI NLN_tile where ntile is included.
http://www.nlneilson.com/apps/01.zip

Here is how it is tied in:
    void Work(){
		FileOut out("nt.bat");
		if(!out) {
		    Exclamation("Unable to open [* " + DeQtf(cfgfile));
		    Break();
		}
		out.PutLine("call cd C:\\0-Neil\\FAA\\2011\\Sectionals");	
//		out.PutLine("call ntile.exe  tile --lztsd 10.0 --wwcache --overviews  0nt5 LA_clip.tif"); // 2	
//		out.PutLine("pause"); // 2	
		out.Close();
		system ("nt.bat");
		ntile(????????);


It took me a while to figure this out:
#include "ntile.cpp"

ntile.exe has been working OK and when nt.bat is made it works with the GUI, here I just hard coded the data in the nt.bat file, renamed main in ntile.cpp to ntile and commemted the argv hard coded in ntile.cpp and un commented this line:
		out.PutLine("call ntile.exe  tile --lztsd 10.0 --wwcache --overviews  0nt5 LA_clip.tif");


I have not figured out how to pass the argv from the GUI to the ntile function.

[Updated on: Thu, 09 June 2011 11:00]

Report message to a moderator

Re: MSVC 10 to Upp conversion [message #32792 is a reply to message #32773] Thu, 09 June 2011 23:28 Go to previous messageGo to next message
nlneilson is currently offline  nlneilson
Messages: 644
Registered: January 2010
Location: U.S. California. Mojave &...
Contributor
Hi Koldo

Quote:

ERROR 4: Unable to open EPSG support file gcs.csv.


It's not linked with FWTools\bin.

How the original dstile was used was dstile.exe was placed in FWTools\bin. Try placing the ntile.exe and the dstile.exe in the bin and you can try both.

Then right clicking on the FWTools icon then change Properties->Start in: to the directory the image files are in.
Then just open FWTools with a left click and enter the command line in the FWTools dos box that is opened:
dstile.exe tile --lztsd 10.0 --wwcache --overviews 0nt LA_clip.tif

Changing dstile.exe on the command line to the U++ compiled ntile.exe works the same way except it has the changes in the code.

To debug the code in U++ this was done:
In the FWTools Properties->Target: it has:
 C:\WINDOWS\system32\cmd.exe /K "C:\FWTools2.4.7\setfw.bat"

This sets the environment.
So in the ntile code I added this so no changes to the FWTools properties need to be changed:
	system ("C:/FWTools2.4.7/setfw.bat /K");

Then hard coded the args.

To run from the U++ GUI the hard coded args were commented.
Making the nl.bat to pass the args the line
		out.PutLine("call cd C:\\0-Neil\\FAA\\2011\\Sectionals");

had to have the double \\ instead of the single \.

The problem of doing it that way is it is run by the .bat file using the ntile.exe that has been placed in FWTools\bin and there is no way to pass data back to the GUI.

And there is no way to debug the ntile code included with the GUI package because it is not used.

Maybe calling the ntile function included with the GUI code:
      ntile("tile --lztsd 10.0 --wwcache --overviews  0nt LA_clip.tif");

is something I will try next.

Note that the ntile.exe placed in the FWTools\bin doesn't have any hard coded args, etc., just the code as compiled in MSVC 10 except when compiled in U++ some changes were made as far as the output format, etc..

Sorry my explanations and current code is lacking, still tinkering.

Your help with the linking, compiling in U++ is much appreciated.

[Updated on: Thu, 09 June 2011 23:34]

Report message to a moderator

Re: MSVC 10 to Upp conversion [message #32793 is a reply to message #32792] Fri, 10 June 2011 01:19 Go to previous messageGo to next message
nlneilson is currently offline  nlneilson
Messages: 644
Registered: January 2010
Location: U.S. California. Mojave &...
Contributor
Maybe just a basic GUI which does all the checking (I have not included that yet) and runs the ntile.exe placed in the FWTools\bin will work for now.

I just have the data for the nt.bat hard coded rather than GUI input but works OK. No progress bar so a user just sees the progress in the dos box.

Just clicking File->Run tiler in N_tile works for my setup.
This will require a user to to place ntile.exe in the FWTools\bin rather than have a stand alone GUI with ntile built in.

http://www.nlneilson.com/apps/N_tile.zip
Re: MSVC 10 to Upp conversion [message #32794 is a reply to message #32793] Fri, 10 June 2011 03:36 Go to previous messageGo to previous message
nlneilson is currently offline  nlneilson
Messages: 644
Registered: January 2010
Location: U.S. California. Mojave &...
Contributor
Note that all the GUIs has a label FWTools and an edit field that shows "OK".
This is intended to check that ntile.exe is in FWTools\bin or if the FWTools\bin is linked correctly if the GUI is a stand alone .exe with the ntile included.

The previous GUIs had a wide box to show any errors in the dos box that was on top of only the GUI, maybe putting a pause at the end would keep the whole box visible on error.

http://www.nlneilson.com/wwposts/GUI_1.jpg

[Updated on: Fri, 10 June 2011 07:46]

Report message to a moderator

Previous Topic: Please recommend a scripting language
Next Topic: String to std::string conversion
Goto Forum:
  


Current Time: Thu Jul 16 03:27:54 GMT+2 2026

Total time taken to generate the page: 0.01497 seconds