help with Assembling GDAL 1.9.0 (Visual Studio 2010)

Ответить
rudy01
Новоприбывший
Сообщения: 7
Зарегистрирован: 09 апр 2013, 05:27
Репутация: 0

help with Assembling GDAL 1.9.0 (Visual Studio 2010)

Сообщение rudy01 » 09 апр 2013, 05:43

Hi all,
Sorry, I am not a Russian Speaker, and that is why I am writing this in English, and I hope I can get some help from you guys.
Unfortunately, there was not a proper single article in English about how to set up GDAL with VS 2010.
And I came across this article which was very helpful:
http://gis-lab.info/qa/gdal19-vs2010.html

I got all the way to step 'The libjpeg", and when I tried to change line 197 in jmorecfg.h, that is where it broke!

When I changed to following it just didn't work:
/ / # Define EXTERN (type) extern type
# ifdef _WIN32
# ifdef libjpeg_EXPORTS
# define EXTERN (type) extern / * "C" * / __ declspec (dllexport) type
# else
# define EXTERN (type) extern / * "C" * / __ declspec (dllimport) type
# endif
# else
# define EXTERN (type) extern type
# endif

I was getting all this messages that it didn't understand EXTERN..
Well I have to mention my machine is a WIN64, so I even changed _WIN32 to _WIN64, but I don't think that is the issue.

However, when I just leave line 197 unchanged, the library compiles and builds correctly, but I don't get any ".lib" file generated, that is why I am assuming that this step doesn't work for me.

But also, when I tried to build GDAL at the end, the whole thing didn't compile correctly, so it maybe because of not building "libjpeg" correctly.
Can someone please help me get passed this point?

Many thanks in advance,
--Rudy

Аватара пользователя
Дмитрий Барышников
Гуру
Сообщения: 2572
Зарегистрирован: 17 ноя 2009, 19:17
Репутация: 261
Откуда: Москва

Re: help with Assembling GDAL 1.9.0 (Visual Studio 2010)

Сообщение Дмитрий Барышников » 09 апр 2013, 11:20

Hi Rudy,

Please provide the vesions of libjpeg and Visual Studio.

Also, I need the errors from compilator. Copy them here too.

The # ifdef _WIN32 is need for Windows PC. It's no different 32-bit or 64-bit. I afraid, that _WIN64 is not exist definition. Maybe this is the problem.

rudy01
Новоприбывший
Сообщения: 7
Зарегистрирован: 09 апр 2013, 05:27
Репутация: 0

Re: help with Assembling GDAL 1.9.0 (Visual Studio 2010)

Сообщение rudy01 » 09 апр 2013, 23:17

Hi Дмитрий,
Thanks for the reply.
I tried to keep almost all the versions the same. So, I am using jpeg-8d, and I am using "Visual Studio 2010" Version 10.0.402191.1 SP1Rel

If I don't change anything, everything builds okay, but in C:\projects\jpeg-8d\lib\Release, I only see libjpeg.dll.
I am not sure whether this is okay or not!
Because I was expecting to see something like "libjpeg.lib" or something like this.

And, when I make the change, I get bunch of errors, like this:

error C2054: expected '(' to follow 'type'

When when I double click it is pointing to line 928 of "jpeglib.h", and I see a red line under EXTERN, and when I hover the mouse over it, it says:

#define EXTERN (type) extern __declspec (dllexport) type
"Error: this declaration has no storage class or type specifier"

Which indicates that it sees EXTERN as declspec (dllexport) type, but it yet doesn't understand it !!

And I get bunch of similar errors, I get the same error for line 944, 946, 949, ..., 1091 of "jpeglib.h"

And, obviously I get the following errors for the exact same lines:

error C2143: synthax error: missing ';' before '/'

which makes sense since it cannot understand EXTERN.

I tried to put different variation for the replacement code, but it didn't work worked.

For example, I tried these:

# ifdef _WIN64
# ifdef libjpeg_EXPORTS
# define EXTERN (type) extern "C" __ declspec (dllexport) type
# else
# define EXTERN (type) extern "C" __ declspec (dllimport) type
# endif
# else
# define EXTERN (type) extern type
# endif

----------------

But again the same set of errors:
error C2054: expected '(' to follow 'type'

When I double clicked, it is pointing to line 928 of "jpeglib.h", this time I don't see the red line under EXTERN complaining that there is no class storage for the declaration, however, for some reason it still doesn't like it!!!

I would appreciate some help.
Thanks,
--Rudy
Последний раз редактировалось rudy01 10 апр 2013, 01:56, всего редактировалось 1 раз.

Аватара пользователя
Дмитрий Барышников
Гуру
Сообщения: 2572
Зарегистрирован: 17 ноя 2009, 19:17
Репутация: 261
Откуда: Москва

Re: help with Assembling GDAL 1.9.0 (Visual Studio 2010)

Сообщение Дмитрий Барышников » 10 апр 2013, 00:46

Hi, try this:
1. Get last libjpeg here http://www.ijg.org/files/jpegsr9.zip
2. Extract archive to your working folder, i.e. c:/projects/jpeg-9
3. Extract to this folder additional files from attached archive.
jpeg-9.zip
(6.23 КБ) 515 скачиваний
You need overwrite jmorecfg.h file with one from archive. If Windows don't notify you to overwrite - you extract to the wrong folder.

This works on my PC with 32-bit and 64-bit version of comiler.
Вложения
cmake.png
cmake.png (62.09 КБ) 11443 просмотра

rudy01
Новоприбывший
Сообщения: 7
Зарегистрирован: 09 апр 2013, 05:27
Репутация: 0

Re: help with Assembling GDAL 1.9.0 (Visual Studio 2010)

Сообщение rudy01 » 10 апр 2013, 05:19

Okay NICE.
Thanks a lot. I was able to pass this point, when I used jpeg-9, and the cmake files that you included.
And, throughout building the reset of the libraries I didn't get any errors.

But, at the last step, which was buidling GDAL, it didn't compile, and I got bunch of errors.


Could you please look at the snapshot that I included, and see if you can spot something wrong with it?






Also, some of the libraries like GEOS has few libraries, "geos.lib", "libgeos.lib", and "c_geos.lib".
Does it look like that I added them correctly? Do I need to include all of them individually? (please look the snapshot that I provided).

Do I need to somehow add all the "dll" into the final GDAL library as well?
And, one other thing that gave me an error in cmake was that I have to NOT list "C:\projects\geos-3.3.2\build", in GEOS_INCLUDE_DIR, and I only have to include "C:\projects\geos-3.3.2" !!!
When I listed "C:\projects\geos-3.3.2\build", I got the following error:

CMake Error at cmake/ogr.cmake:26 (get_filename_component):
get_filename_component unknown component C:\projects\geos-3.3.2\build
Call Stack (most recent call first):
CMakeLists.txt:110 (include)

So, I exclude "C:\projects\geos-3.3.2\build", and I have no more errors. But when I proceed with compiling gdallib.sln,

I got the following errors:

error C1083: Cannot open include file: 'curl/curl.h': No such file or directory
error C1083: Cannot open include file: 'expat.h': No such file or directory
error C1083: Cannot open include file: 'geos_c.h': No such file or directory
error C1083: Cannot open include file: 'proj_api.h': No such file or directory
error C1083: Cannot open include file: 'tiffio.h': No such file or directory


Many thanks for the help,
--Rudy
Вложения
cmake.png
cmake.png (55.54 КБ) 11426 просмотров

Аватара пользователя
Дмитрий Барышников
Гуру
Сообщения: 2572
Зарегистрирован: 17 ноя 2009, 19:17
Репутация: 261
Откуда: Москва

Re: help with Assembling GDAL 1.9.0 (Visual Studio 2010)

Сообщение Дмитрий Барышников » 10 апр 2013, 10:28

You need to fix some paths:
CURL_INCLUDE_DIR -> C:/project/curl-7.24.0/include
EXPAT_INCLUDE_DIR -> C:/project/expat-2.0.1/lib/
GEOS_INCLUDE_DIR -> C:/project/geos-3.3.2/include
GEOS_LIBRARY -> C:/project/geos-3.3.2/lib/Release/geos_c.lib
PROJ_INCLUDE_DIR -> C:/project/proj-4.8.0/src
TIFF_INCLUDE_DIR -> C:/project/tiff-4.0.1/libtiff;C:/project/tiff-4.0.1/build
PNG_LIBRARY -> C:/project/lpng159/lib/Release/libpng15.lib

You can copy the path from here and past them to cmake-gui.
The paths is so different, because this are the different projects, and they have their own point of view on sources and include paths.

rudy01
Новоприбывший
Сообщения: 7
Зарегистрирован: 09 апр 2013, 05:27
Репутация: 0

Re: help with Assembling GDAL 1.9.0 (Visual Studio 2010)

Сообщение rudy01 » 10 апр 2013, 20:10

Thanks again,
After fixing the above paths, I can see that I get passed the errors related to not being able to find a specific path. However, now I got bunch of LNK errors, that I have provided a snapshot for.
Am I still missing some stuff? Do I still need to include something else that I forgot about?

Thanks again in advance for your support.

(It looks like it is all regarding "jpgdataset.obj")

Here is the snapshot for the list of errors that I get:
Вложения
error.png
error.png (135.08 КБ) 11371 просмотр

rudy01
Новоприбывший
Сообщения: 7
Зарегистрирован: 09 апр 2013, 05:27
Репутация: 0

Re: help with Assembling GDAL 1.9.0 (Visual Studio 2010)

Сообщение rudy01 » 10 апр 2013, 22:43

Update:
Nice, I had it all compiled fine. It is not complaining anymore. I revisited each single library, and I rebuilt each one with its "Cmake" again, and this time, when I built the final step for GDAL, it didn't complain.
So with many thanks to your help, I was able to compile it correctly.

Now, when I try to write the test case, I get an error. I guess I am not sure what "pszFilename" is?

I just put a sample jpg in my debug directory, and tried this:

#include "gdal_priv.h"
int main()
{
GDALDataset * poDataset;

GDALAllRegister ();
char pszFilename[30] = "testorig.jpg";

poDataset = (GDALDataset *) GDALOpen (pszFilename, GA_ReadOnly);
if (NULL == poDataset)
{
cout << "this is not working" << endl;
}
return 0;
}

But, I get the following message printed out:

ERROR 4: 'testorig.jpg' does not exist in the file system, and is not recognised as a supported dataset name.

I am sorry, but I don't know what is "pszFilename"?

Can someone tell me what kind of file does "pszfilename" have to be? I just want to make sure that I have all the necessary libraries setup, so I can start digging into learning GDAL.

By the way, Could someone please point me to some tutorial about GDAL?

Many thanks,
--Rudy

Аватара пользователя
Дмитрий Барышников
Гуру
Сообщения: 2572
Зарегистрирован: 17 ноя 2009, 19:17
Репутация: 261
Откуда: Москва

Re: help with Assembling GDAL 1.9.0 (Visual Studio 2010)

Сообщение Дмитрий Барышников » 10 апр 2013, 23:05

Try to set the full path to the testorig.jpg

rudy01
Новоприбывший
Сообщения: 7
Зарегистрирован: 09 апр 2013, 05:27
Репутация: 0

Re: help with Assembling GDAL 1.9.0 (Visual Studio 2010)

Сообщение rudy01 » 10 апр 2013, 23:52

Nice,
That again, that works just fine. Now, I believe I have all the libraries setup properly, well mostly due to the support you provided.

Okay, I just captured a random image from Google Earth, and here is the image.

As it is listed on the bottom of the image, it has some geographical information.
But how come when I run the image through the sample test, it only grabs the following information

Driver: JPEG / JPEG JFIF
Size: 944x588x3
The projection of ""


And it skips over providing some data for the following fields?

adfGeoTransform[0] /* top left x */
adfGeoTransform[1] /* w-e pixel resolution */



Here is the sample code that I copied

double adfGeoTransform [6];

printf ( "Driver: %s / %s \n" ,
poDataset->GetDriver()->GetDescription(),
poDataset->GetDriver()->GetMetadataItem(GDAL_DMD_LONGNAME)
);

printf ( "Size: %dx%dx%d \n" ,
poDataset->GetRasterXSize(), poDataset->GetRasterYSize(),
poDataset->GetRasterCount()
);

if (poDataset->GetProjectionRef() != NULL)
printf ( "The projection of \"%s\"\n" , poDataset->GetProjectionRef());

if (poDataset->GetGeoTransform(adfGeoTransform) == CE_None)
{
printf ( "origin is (%.6f, %.6f) \n" ,
adfGeoTransform[0], adfGeoTransform [3]);

printf ( "Pixel size (%.6f,%.6f) \n" ,
adfGeoTransform[1], adfGeoTransform [5]);
}


It gets the image size correctly, but doesn't get the other information.

I've attached the random geo-referenced file, just in case.

Thanks,
--Rudy
Вложения
loc1.jpg
loc1.jpg (74.42 КБ) 11324 просмотра

rudy01
Новоприбывший
Сообщения: 7
Зарегистрирован: 09 апр 2013, 05:27
Репутация: 0

Re: help with Assembling GDAL 1.9.0 (Visual Studio 2010)

Сообщение rudy01 » 11 апр 2013, 02:14

Update:
Never mind, I think I was able to get some information. I guess the problem was the Google Earth doesn't capture any of those information. I downloaded this evaluation version of this tool called "Shape2Earth Globe", and now when I capture an image with this tool, it stores all the necessary information along with it, and when I try to read it with the GDAL test program, it just works fine.

For example, I got something like this:


C:\Users\Rudy\Documents\Visual Studio 2010\Projects\gdal_tutorial\x64\Release>gdal_tutorial.exe
Driver: JPEG / JPEG JFIF
Size: 1020x619x3
The projection of "GEOGCS["GCS_WGS_1984",DATUM["WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0
174532925199433]]"
origin is (-108.218874, 38.187301)
Pixel size (0.000879,-0.000691)


Thank you so much for all the help.
--Rudy

Ответить

Вернуться в «GDAL/OGR»

Кто сейчас на конференции

Сейчас этот форум просматривают: нет зарегистрированных пользователей и 0 гостей