473,386 Members | 1,864 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Troubles with Glib/Gtk dependend 3rd party libraries... Gwyddion

Hey all,

Gwyddion is a modular program for scanning probe microscopy data visualization and analysis. I've been trying to use some of the libraries provided (in C++, and heavily Glib/gtk dependent) to load the proprietary file formats that are native to particular atomic microscope devices. The goal is to write a simple file conversion program using these libraries. I'm currently using Microsoft Visual Studio 2010 on a 64-bit Vista machine. I've run in to some difficulty that I've been unable to resolve as yet.

The relevant code is as follows:

Expand|Select|Wrap|Line Numbers
  1.  
  2. int main(int argc, char *argv[])
  3. {
  4.     /* Name of the file to display */
  5.     const gchar *filename = argv[1];
  6.  
  7.     if(argc != 2){
  8.         std::cout << "Usage: mi2bitmap <filename>" << std::endl;        
  9.         return 1;    
  10.     }    
  11.  
  12.     /* Error Initialization */
  13.     GError *err = NULL;
  14.  
  15.     /* The data file contents */
  16.     GwyContainer *data = NULL;
  17.  
  18.     /* Initialize Gtk+ */
  19.         gtk_init(&argc, &argv);
  20.  
  21.     /* Initialize Gwyddion stuff */
  22.     gwy_app_init_common(&err, "layer", "file", NULL);
  23.  
  24.     /* Name of the file to export as */
  25.     const gchar *extension = "jpeg";
  26.  
  27.     gchar *mpath = gwy_find_self_dir("");
  28.     gchar *importfilenamefull = g_build_filename(mpath, "\\" , filename, NULL);
  29.     gchar *exportfilenamefull = g_build_filename(mpath, "\\" , filename, ".", extension, NULL);
  30.     gchar *gfilename = g_filename_to_utf8(gwy_canonicalize_path(importfilenamefull), -1, NULL, NULL, &err);
  31.     gchar *gfilename_x = g_filename_from_utf8(gwy_canonicalize_path(exportfilenamefull), -1, NULL, NULL, &err);
  32.  
  33. std::cout << gwy_file_detect(gfilename, TRUE, GWY_FILE_OPERATION_DETECT) << std::endl;
  34.  
  35.     /* Load the file */
  36.  
  37.     data = gwy_file_load(gfilename, GWY_RUN_NONINTERACTIVE, &err);
  38.  
  39.     if (!data) {
  40.         std::cout << std::endl;
  41.         g_printerr("File load error: Cannot load `%s': %s\n", argv[1], err->message);
  42.         g_clear_error(&err);
  43.         return 1;
  44.     }
  45.  
  46.  
  47.     /* Free Resources */
  48.     g_free(&filename);
  49.     g_free(mpath);
  50.     g_free(err);
  51.     g_free(gfilename);
  52.     g_free(gfilename_x);
  53.     g_free(exportfilenamefull);
  54.     g_free(importfilenamefull);
  55.     g_object_unref(data);
  56.  
  57. return 0;
  58. }
  59.  
  60.  

If I comment out gwy_file_load, it seems that gwy_file_load fails, throwing the error " Cannot load `sample.mi': No module can load this file type." This failure persists for any file type I try. More telling though, is that gwy_detect_file will cause the program to crash with "Unhandled exception at 0x5ef3d540 (msvcr100d.dll) in mi2bitmap.exe: 0xC0000005: Access violation reading location 0x00000000." It seems as though I'm deferencing a null pointer somewhere, but the crash occurs with any value I set the first argument as in gwy_detect_file. The documentation for these file loading functions can be found here.

This is probably a bit of a long shot, as I suspect that few if any here are familiar with Gwyddion, but perhaps Glib/Gtk experience will help, and as a complete C++ beginner I'd appreciate any help I can get with this.

Thanks very much.

Edit: the debugger seems to indicate that the crash occurs at this line in the stack:

main_loop:
mov eax,dword ptr [ecx] ; read 4 bytes
Jun 21 '10 #1
0 1099

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Thato | last post by:
I've been trying to link the svlib (a library) as you showed me, I want to link third party library to borland55 compiler. I tried all possible combinations using the bcc32 borland guide, it...
1
by: primi | last post by:
Hello, i have studied both c and c++ at university (although by no means have they been extensive, one semester each) and i feel i have a fairly good understanding of the basics of these languages. ...
2
by: a.kamroot | last post by:
Hi I am new to c# and the .NET environment so I might not be using the right terminology. However. I have downloaded Codeplex's public domain Logging files (and assemblies)...
37
by: josh | last post by:
Hi, any idea about what third-party library can I use to improve my Javascript UI YUI ? Google ? script.aculo.us ? or others?
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.