|
|
Home » Community » Newbie corner » MSVC 10 to Upp conversion
MSVC 10 to Upp conversion [message #32638] |
Mon, 30 May 2011 22:22 |
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 #32642 is a reply to message #32640] |
Tue, 31 May 2011 01:39 |
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 #32645 is a reply to message #32643] |
Tue, 31 May 2011 08:03 |
|
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 |
|
koldo
Messages: 3361 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 .
Best regards
Iñaki
|
|
|
Re: MSVC 10 to Upp conversion [message #32649 is a reply to message #32648] |
Tue, 31 May 2011 12:29 |
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 #32662 is a reply to message #32660] |
Wed, 01 June 2011 02:59 |
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 283 times)
[Updated on: Wed, 01 June 2011 05:20] Report message to a moderator
|
|
|
|
|
|
Re: MSVC 10 to Upp conversion [message #32671 is a reply to message #32668] |
Wed, 01 June 2011 11:29 |
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
|
|
|
|
|
|
|
|
Goto Forum:
Current Time: Mon May 13 08:32:33 CEST 2024
Total time taken to generate the page: 0.02921 seconds
|
|
|