Posts tagged ‘error lnk2019: unresolved external symbol _ getprocessmemoryinfo@12 referenced in function “void __cdecl printmemoryinfo(unsigned long’
Compiling Errors on GetProcessMemoryInfo function
I recently used GetProcessMemoryInfo function to measure memory usage of working processes on Windows. I firstly tried with the example code “Collecting Memory Usage Information For a Process” in MSDN but the compiling produced some external linking errors on my Windows XP box:
Error 1 error LNK2019: unresolved external symbol _GetProcessMemoryInfo@12 referenced in function “void __cdecl PrintMemoryInfo(unsigned long)” (?PrintMemoryInfo@@YAXK@Z)
Error 2 error LNK2019: unresolved external symbol _EnumProcesses@12 referenced in function _main
Error 3 fatal error LNK1120: 2 unresolved externals
To fix this issue, I added “pragma comment” instruction to places a library-search record in the object file and compiling is now working fine.
#include <windows.h>
#include <stdio.h>
#include <psapi.h>
#pragma comment(lib, “psapi.lib”) //added
IBM Quest Market-Basket Synthetic Data Generator
I recently need IBM Quest Market-Basket Synthetic Data Generator for my study on association rule mining. After a lot of web search effort, I finally found the program source code at the project’s website. There are also many instructions available here. The link to this website has broken recently and I could not find where the site moved to. However, the compling of original source code was failed on my Red Hat 4.1 box. These code was written around 1996 for IBM compliler so some small changes are needed to make it work such as replacing complier by g++ in Makefile, revising code in gen.h file. You can download the converted code at the link
http://www.cs.indiana.edu/~cgiannel/assoc_gen.html
However, this code still did not work on my machine. It produced a lot of errors while compliling gen object.
gen.h:185: error: ‘StringSet’ has not been declared
gen.C: In member function ‘void Taxonomy::write_asc(std::ofstream&)’:
gen.C:183: error: ‘setw’ was not declared in this scope
gen.C: In member function ‘void ItemSet::display(std::ofstream&)’:
gen.C:334: error: ‘setprecision’ was not declared in this scope
gen.C: In member function ‘void String::display(std::ofstream&,LINT)’:
gen.C:380: error: ‘setw’ was not declared in this scope
gen.C: At global scope:
gen.C:387: error: prototype for ‘void String::display(std::ofstream&,StringSet&, LINT)’ does not match any in class ‘String’
gen.h:185: error: candidates are: void String::display(std::ofstream&,int&, LINT)
gen.C:378: error: void String::display(std::ofstream&,LINT)
gen.C: In member function ‘void String::display(std::ofstream&,StringSet&, LINT)’:
gen.C:392: error: ‘setw’ was not declared in this scope
gen.C: In member function ‘void StringSet::display(std::ofstream&)’:
gen.C:580: error: ‘setprecision’ was not declared in this scope
gen.C:584: error: call of overloaded ‘display(std::basic_ofstream<char, std::char_traits<char> >&, LINT&)’
is ambiguous
gen.C:378: note: candidates are: void String::display(std::ofstream&,LINT)
gen.h:185: note: void String::display(std::ofstream&,int&, LINT)
gen.C:587: error: call of overloaded ‘display(std::basic_ofstream<char, std::char_traits<char> >&, LINT&)’
is ambiguous
gen.C:378: note: candidates are: void String::display(std::ofstream&, LINT)
gen.h:185: note: void String::display(std::ofstream&,int&, LINT)
gen.C: In member function ‘void StringSet::display(std::ofstream&,StringSet&)’:
gen.C:597: error: ‘setprecision’ was not declared in this scope
gen.C: In member function ‘void Transaction::write_asc(std::ofstream&,LINT)’:
gen.C:775: error: ‘setw’ was not declared in this scope
make.exe: *** [gen.o] Error 1
To fix this issue, I simply added the missing include instructions and declared StringSet class at the top of gen.h file. And now compliling worked well on my machine.
#include “glob.h”
#include “dist.h”
#include <stream.h>
#include <fstream>
#include <iostream>
#include <string>
#include <iomanip> //for settw
using namespace std;class StringSet;