아래와 같은 에러로그가 발생한다면,

 

error LNK2001: unresolved external symbol __imp__SelectObject@8
error LNK2001: unresolved external symbol __imp__CreateFontA@56
error LNK2001: unresolved external symbol __imp__CreateWindowExA@48
error LNK2001: unresolved external symbol __imp__GetWindowLongA@8
error LNK2001: unresolved external symbol __imp__UnregisterClassA@8
error LNK2001: unresolved external symbol __imp__SetWindowLongA@12
error LNK2001: unresolved external symbol __imp__ShowCursor@4
error LNK2001: unresolved external symbol __imp__GetDC@4
error LNK2001: unresolved external symbol __imp__WaitMessage@0
error LNK2001: unresolved external symbol __imp__ChangeDisplaySettingsA@8
error LNK2001: unresolved external symbol __imp__RegisterClassExA@4
error LNK2001: unresolved external symbol __imp__SwapBuffers@4
error LNK2001: unresolved external symbol __imp__DestroyWindow@4
error LNK2001: unresolved external symbol __imp__SetPixelFormat@12
error LNK2001: unresolved external symbol __imp__LoadCursorA@8
error LNK2001: unresolved external symbol __imp__ChoosePixelFormat@8
error LNK2001: unresolved external symbol __imp__AdjustWindowRectEx@16
error LNK2001: unresolved external symbol __imp__DispatchMessageA@4
error LNK2001: unresolved external symbol __imp__PostMessageA@16
error LNK2001: unresolved external symbol __imp__ShowWindow@8
error LNK2001: unresolved external symbol __imp__DefWindowProcA@16
error LNK2001: unresolved external symbol __imp__ReleaseDC@8
error LNK2001: unresolved external symbol __imp__PeekMessageA@20

 

다음과 같이 수정합니다.

Hit the + next to Configuration Properties
Hit the + next to Linker
Select Input
On the right, you'll see 'Additional Dependencies'
Add the following:
kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib
It will work.

필자는 Debug mode로 빌드 했던 것을 릴리즈 모드로 변경하여 배포할 때,

이런 에러메시지를 보았습니다.

by JNexOnSoft 2014. 4. 2. 15:53

LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup

웹서핑하다가 좋은팁이 있어서 올립니다.

(Win32 project - empty project 로 생성 후, 빌드시 만나 볼수 있는 LNK2019에 대한 대처법입니다.)

 

When trying to compile a command line (non-GUI) program with Visual Studio I got the error:

LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup

I’ve had this before and so have lots of others – it’s a continual question out there on the web – this is to provide at least one answer hopefully.

I went to:

Project  Properties -> Linker -> System -> SubSystem

and set it to

Console (/SUBSYSTEM:CONSOLE)

rather than

Windows (/SUBSYSTEM:WINDOWS)

That suggested to the linker that maybe the program entry point should be “main” rather than “WinMain”

by JNexOnSoft 2014. 2. 13. 14:39

Xcode 에서 run 선택시 release mode 로 바이너리 생성 후 실행하는 방법입니다.


Xcode 메뉴에서 Product > Scheme > Edit Scheme 을 선택하면 [그림 1]의 화면이 나타납니다.


[그림 1]


[Build Configuration] 항목을 "Release" 로 설정하면 Build 시 Release Mode 로 바이너리가 생성됩니다.


by JNexOnSoft 2014. 1. 28. 18:23

이 글은 wxWidgts 설치 및 sample code 를 만들어 실행시키는 방법을 설명한다.

 

wxWidgets is a C++ library that lets developers create applications for Windows, OS X, Linux and UNIX on 32-bit and 64-bit architectures as well as several mobile platforms including Windows Mobile, iPhone SDK and embedded GTK+. (http://www.wxwidgets.org/)

 

1. wxWidgets 설치

 

wxWidgets is not built into useable libraries when you "install" the wxMSW installer. This is because there are so many configurable elements, which is precisely what the setup.h you refer to is for.
If you just want to build it with default options as quickly as possible and move on, here is how:

1) Start the "Visual Studio Command Prompt." You'll find this in the start menu under "Microsoft Visual Studio -> Visual Studio Tools".

2) Change to folder: [WXWIN root]\build\msw

3) Build default debug configuration: nmake -f makefile.vc BUILD=debug

4) Build default release configuration: nmake -f makefile.vc BUILD=release

5) Make sure the DLLs are in your PATH. They'll be found in [WXWIN root]\lib\vc_dll

6) Under the DLL folder mentioned above, you will find subfolders for each build variant (The instructions above made two, debug and release.) In each variant folder you'll find a 'wx' folder containing a 'setup.h" file. You'll see that the setup.h files are actually different for each build variant. These are the folders you need to add to your project build configuration include path, one per build variant. So, for example, you'd add [WXWIN root]\lib\vc_dll\mswud to the include path for your debug build, [WXWIN root]\lib\vc_dll\mswu for your release build.

7) It is possible to build lots of other variant combinations: static libs, monolithic single library, non-Unicode, etc. See [WXWIN root]\docs\msw\install.txt for much more extensive instructions.

 

2. Sample Program 생성

 

- Win32 Application 프로젝트 선택 -> empty project 선택 후 생성

- [source files] 에 hello.cpp 파일을 추가한 후, 아래 내용을 해당 파일에 복사한다.

/*
 * hworld.cpp
 */

#include "wx/wx.h"

class MyApp: public wxApp
{
    virtual bool OnInit();
};

class MyFrame: public wxFrame
{
public:

    MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size);

    void OnQuit(wxCommandEvent& event);
    void OnAbout(wxCommandEvent& event);

    DECLARE_EVENT_TABLE()
};

enum
{
    ID_Quit = 1,
    ID_About,
};

BEGIN_EVENT_TABLE(MyFrame, wxFrame)
    EVT_MENU(ID_Quit, MyFrame::OnQuit)
    EVT_MENU(ID_About, MyFrame::OnAbout)
END_EVENT_TABLE()

IMPLEMENT_APP(MyApp)

bool MyApp::OnInit()
{
    MyFrame *frame = new MyFrame( _("Hello World"), wxPoint(50, 50),
                                  wxSize(450,340) );
    frame->Show(true);
    SetTopWindow(frame);
    return true;
}

MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size)
: wxFrame( NULL, -1, title, pos, size )
{
    wxMenu *menuFile = new wxMenu;

    menuFile->Append( ID_About, _("&About...") );
    menuFile->AppendSeparator();
    menuFile->Append( ID_Quit, _("E&xit") );

    wxMenuBar *menuBar = new wxMenuBar;
    menuBar->Append( menuFile, _("&File") );

    SetMenuBar( menuBar );

    CreateStatusBar();
    SetStatusText( _("Welcome to wxWidgets!") );
}

void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
{
    Close(TRUE);
}

void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
{
    wxMessageBox( _("This is a wxWidgets Hello world sample"),
                  _("About Hello World"),
                  wxOK | wxICON_INFORMATION, this);
}

- project properties -> Configuration Properties -> C/C++ -> General -> Additional Include Directories -> wxWidgets 설치 include 디렉토리 추가 "C:\work\wxWidgets-3.0.0\include;C:\work\wxWidgets-3.0.0\include\msvc"

- project properties -> Configuration Properties -> Linker -> General -> Additional Library Directories -> wxWidgets 설치 lib 디렉토리 추가 "C:\work\wxWidgets-3.0.0\lib\vc_lib;"

 

3. 빌드 및 실행

 

위의 코드를 빌드 후 실행시키면, 아래와 같은 윈도우를 볼 수 있다.

 

 

 

by JNexOnSoft 2013. 12. 7. 21:30

"close was not declared in this scope" 라는 빌드 에러메시지가 나타날 때,

 

#include <unistd.h>

를 추가 하도록 한다.

by JNexOnSoft 2013. 12. 6. 11:43

kali 1.0.5 에서 qmake 는 이미 설치되어 있다.

따라서 개발 환경을 위해 아래와 같이 명령을 입력한다.


# apt-get install qtcreator

Reading package lists... Done
Building dependency tree      
Reading state information... Done
The following extra packages will be installed:
  libqt4-declarative-gestures libqt4-declarative-particles qt4-demos
  qt4-designer qt4-dev-tools qt4-doc qt4-qmlviewer qtcreator-doc
Suggested packages:
  qt4-doc-html cmake kdelibs5-data
The following NEW packages will be installed:
  libqt4-declarative-gestures libqt4-declarative-particles qt4-demos
  qt4-designer qt4-dev-tools qt4-doc qt4-qmlviewer qtcreator qtcreator-doc
0 upgraded, 9 newly installed, 0 to remove and 0 not upgraded.
Need to get 131 MB/132 MB of archives.
After this operation, 209 MB of additional disk space will be used.
Do you want to continue [Y/n]? Y
Get:1 http://http.kali.org/kali/ kali/main qt4-demos i386 4:4.8.2+dfsg-11 [9,774 kB]
Get:2 http://http.kali.org/kali/ kali/main qt4-designer i386 4:4.8.2+dfsg-11 [389 kB]
Get:3 http://http.kali.org/kali/ kali/main qt4-dev-tools i386 4:4.8.2+dfsg-11 [3,925 kB]
Get:4 http://http.kali.org/kali/ kali/main qt4-doc all 4:4.8.2+dfsg-11 [95.4 MB]
Get:5 http://http.kali.org/kali/ kali/main qt4-qmlviewer i386 4:4.8.2+dfsg-11 [189 kB]
Get:6 http://http.kali.org/kali/ kali/main qtcreator i386 2.5.0-2 [17.8 MB]   
Get:7 http://http.kali.org/kali/ kali/main qtcreator-doc all 2.5.0-2 [4,018 kB]
Fetched 131 MB in 1h 6min 48s (32.7 kB/s)                                     
Selecting previously unselected package libqt4-declarative-gestures:i386.
(Reading database ... 290780 files and directories currently installed.)
Unpacking libqt4-declarative-gestures:i386 (from .../libqt4-declarative-gestures_4%3a4.8.2+dfsg-11_i386.deb) ...
Selecting previously unselected package libqt4-declarative-particles:i386.
Unpacking libqt4-declarative-particles:i386 (from .../libqt4-declarative-particles_4%3a4.8.2+dfsg-11_i386.deb) ...
Selecting previously unselected package qt4-demos.
Unpacking qt4-demos (from .../qt4-demos_4%3a4.8.2+dfsg-11_i386.deb) ...
Selecting previously unselected package qt4-designer.
Unpacking qt4-designer (from .../qt4-designer_4%3a4.8.2+dfsg-11_i386.deb) ...
Selecting previously unselected package qt4-dev-tools.
Unpacking qt4-dev-tools (from .../qt4-dev-tools_4%3a4.8.2+dfsg-11_i386.deb) ...
Selecting previously unselected package qt4-doc.
Unpacking qt4-doc (from .../qt4-doc_4%3a4.8.2+dfsg-11_all.deb) ...
Selecting previously unselected package qt4-qmlviewer.
Unpacking qt4-qmlviewer (from .../qt4-qmlviewer_4%3a4.8.2+dfsg-11_i386.deb) ...
Selecting previously unselected package qtcreator.
Unpacking qtcreator (from .../qtcreator_2.5.0-2_i386.deb) ...
Selecting previously unselected package qtcreator-doc.
Unpacking qtcreator-doc (from .../qtcreator-doc_2.5.0-2_all.deb) ...
Processing triggers for desktop-file-utils ...
Processing triggers for gnome-menus ...
Processing triggers for menu ...
Processing triggers for man-db ...
Processing triggers for hicolor-icon-theme ...
Processing triggers for shared-mime-info ...
Setting up libqt4-declarative-gestures:i386 (4:4.8.2+dfsg-11) ...
Setting up libqt4-declarative-particles:i386 (4:4.8.2+dfsg-11) ...
Setting up qt4-demos (4:4.8.2+dfsg-11) ...
Setting up qt4-designer (4:4.8.2+dfsg-11) ...
update-alternatives: using /usr/bin/designer-qt4 to provide /usr/bin/designer (designer) in auto mode
Setting up qt4-dev-tools (4:4.8.2+dfsg-11) ...
update-alternatives: using /usr/bin/assistant-qt4 to provide /usr/bin/assistant (assistant) in auto mode
update-alternatives: using /usr/bin/linguist-qt4 to provide /usr/bin/linguist (linguist) in auto mode
Setting up qt4-doc (4:4.8.2+dfsg-11) ...
Setting up qt4-qmlviewer (4:4.8.2+dfsg-11) ...
Setting up qtcreator (2.5.0-2) ...
Setting up qtcreator-doc (2.5.0-2) ...
Processing triggers for menu ...

- [Applications]-[Programming] 메뉴에서 [QT Creator] 를 실행 시킨 후,

[File]-[New File or Project] 메뉴를 통해 "Qt Gui Appliction" 을 하나 생성하여 실행시키면,

아래와 같은 창을 볼 수 있다.

(개인적으로 KDE UI를 더 이뻐라 한다. 아래창 너무 썰렁해 보인다.)

 

 

by JNexOnSoft 2013. 10. 15. 17:23

- gtk 2 설치

apt-get install libgtk2.0-dev 를 실행시킨 후 Y를 입력한다.

(root 로그인이 아닌 경우는 sudo apt-get install libgtk2.0-dev )

 

- gtk 3 설치

#apt-get install libgtk-3-dev

 

 

- BackTrack5 R2 KDE 환경에서 설치함.

 

- 설치가 잘 되었는지 sample code를 만들어 보자. (http://www.levien.com/gimp/hello.html)

아래 코드를 hello.c 로 저장한다.

 

#include <gtk/gtk.h>

void
hello (void)
{
  g_print ("Hello World\n");
}

void
destroy (void)
{
  gtk_main_quit ();
}

int
main (int argc, char *argv[])
{
  GtkWidget *window;
  GtkWidget *button;

  gtk_init (&argc, &argv);

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_signal_connect (GTK_OBJECT (window), "destroy",
      GTK_SIGNAL_FUNC (destroy), NULL);
  gtk_container_border_width (GTK_CONTAINER (window), 10);

  button = gtk_button_new_with_label ("Hello World");

  gtk_signal_connect (GTK_OBJECT (button), "clicked",
      GTK_SIGNAL_FUNC (hello), NULL);
  gtk_signal_connect_object (GTK_OBJECT (button), "clicked",
     GTK_SIGNAL_FUNC (gtk_widget_destroy),
     GTK_OBJECT (window));
  gtk_container_add (GTK_CONTAINER (window), button);
  gtk_widget_show (button);

  gtk_widget_show (window);

  gtk_main ();

  return 0;
}

 

- compile

# gcc hello.c -o hello `pkg-config --cflags --libs gtk+-2.0`

 

- execution

./hello

 

 

 

 

- 위의 소스 코드를 gtk+-3.0 으로 컴파일 하면 아래와 같이 에러가 발생한다.

 

# gcc hello.c -o hello `pkg-config --cflags --libs gtk+-3.0`
/tmp/ccxtLdWx.o: In function `main':
hello.c:(.text+0x56): undefined reference to `GTK_SIGNAL_FUNC'
hello.c:(.text+0x64): undefined reference to `GTK_OBJECT'
hello.c:(.text+0x80): undefined reference to `gtk_signal_connect'
hello.c:(.text+0xa5): undefined reference to `gtk_container_border_width'
hello.c:(.text+0xc1): undefined reference to `GTK_SIGNAL_FUNC'
hello.c:(.text+0xcf): undefined reference to `GTK_OBJECT'
hello.c:(.text+0xeb): undefined reference to `gtk_signal_connect'
hello.c:(.text+0xf7): undefined reference to `GTK_OBJECT'
hello.c:(.text+0x105): undefined reference to `GTK_SIGNAL_FUNC'
hello.c:(.text+0x113): undefined reference to `GTK_OBJECT'
hello.c:(.text+0x12b): undefined reference to `gtk_signal_connect_object'
collect2: error: ld returned 1 exit status
>> deprecated 함수들이 존재함.

 

- gcc hello.c -o hello `pkg-config --cflags --libs gtk+-3.0` 로 빌드하기 위해서는 아래 코드를 사용하자.

 

#include <gtk/gtk.h> 

void hello(GtkWidget *widget,gpointer data) 

    g_print("Hello GClinux!\n"); 

}

 

gint delete_event(GtkWidget *widget,GdkEvent *event,gpointer data) 

    g_print ("delete event occurred\n"); 

    return(TRUE); 

}

 

void destroy(GtkWidget *widget,gpointer data) 

    gtk_main_quit(); 

 

int main( int argc, char *argv[] ) 

    GtkWidget *window; 

    GtkWidget *button; 

    gtk_init (&argc, &argv); 

    window=gtk_window_new (GTK_WINDOW_TOPLEVEL); 

    g_signal_connect(G_OBJECT(window),"delete_event",G_CALLBACK(delete_event),NULL); 

    g_signal_connect(G_OBJECT(window), "destroy",G_CALLBACK(destroy), NULL); 

    gtk_container_set_border_width (GTK_CONTAINER(window), 10); 

    button = gtk_button_new_with_label ("hello"); 

    g_signal_connect (G_OBJECT(button), "clicked",G_CALLBACK(hello), NULL); 

    g_signal_connect_swapped(G_OBJECT(button), "clicked",G_CALLBACK(gtk_widget_destroy),G_OBJECT(window)); 

    gtk_container_add (GTK_CONTAINER(window), button); 

    gtk_widget_show (button); 

    gtk_widget_show (window);    

    gtk_main();    

    return(0); 

}  

by JNexOnSoft 2013. 10. 11. 09:19

리눅스에서 환경정보를 읽어오는 코드 예제.

 

- showenv.c

#include <stdlib.h>

#include <stdio.h>

 

extern char **environ; // 외우자

 

int main()

{

  char **env = environ;

  while(*env)

  {

    printf("%s\n", *env);

    env++;

  }

}

 

- compile

gcc -o showenv showenv.c

 

- execution

./showenv

 

 

 

by JNexOnSoft 2013. 10. 10. 20:30

linux에서 현재시간을 초단위로 읽어오는 코드.

 

- envtime.c

#include <time.h>

#include <stdio.h>

#include <unistd.h>

 

int main()

{

  int i;

  time_t the_time;

 

  for(i=0; i<10; i++)

  {

    the_time = time((time_t *) 0);

    printf("The time is %ld\n", the_time);

    sleep(2); // 2초 delay   

  }

  return 0;

}

 

- gcc -o envtime envtime.c

- 실행 ./envtime

 

 

 

by JNexOnSoft 2013. 10. 10. 20:21
| 1 |